|
This expression fails to deliver the expected result:
Fraction readFromString: '7/8' => 7
The method Fraction>>readFrom: below fixes this:
readFrom: aStream
"Answer an instance of me as described on the stream, aStream."
| nom denom |
(aStream atEnd or: [aStream peek isLetter])
ifTrue:[ ^0 ].
nom := super readFrom: aStream.
(aStream peekFor: $/)
ifTrue:[ denom := super readFrom: aStream ]
ifFalse:[ denom := 1 ].
^nom / denom
Cheers,
Andre
|