Boolean.st
changeset 8517 c3827ae1ead2
parent 8394 da194de43766
child 8830 df7adfaf1a57
--- a/Boolean.st	Fri Sep 03 14:49:28 2004 +0200
+++ b/Boolean.st	Fri Sep 03 19:11:36 2004 +0200
@@ -63,6 +63,32 @@
      - there must be exactly one instance of each - no more"
 
     self error:'new instances of True/False are not allowed'
+!
+
+readFrom:aStringOrStream onError:exceptionBlock
+    "return a new Boolean, reading a printed representation from aStringOrStream."
+
+    |str word|
+
+    str := aStringOrStream readStream.
+    str skipSeparators.
+    word := str nextAlphaNumericWord.
+    word = 'true' ifTrue:[^ true].
+    word = 'false' ifTrue:[^ false].
+    ^ exceptionBlock value.
+
+    "
+     Boolean readFrom:'true'      
+     Boolean readFrom:'false'     
+     Boolean readFrom:'xxx'  
+     Boolean readFrom:'  true'     
+     Boolean readFrom:'  false'    
+     Boolean readFrom:'true xxx'      
+     Boolean readFrom:'false xxx'     
+
+     Boolean readFromString:'true xxx'   
+     Boolean readFromString:'false xxx'  
+    "
 ! !
 
 !Boolean class methodsFor:'queries'!
@@ -219,5 +245,5 @@
 !Boolean class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Boolean.st,v 1.31 2004-06-11 18:12:22 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Boolean.st,v 1.32 2004-09-03 17:11:36 cg Exp $'
 ! !