[Newbies] Re: Proper fractions?
Blake
blake at kingdomrpg.com
Fri Jul 27 01:01:37 UTC 2007
On Thu, 26 Jul 2007 15:03:36 -0700, Bert Freudenberg
<bert at freudenbergs.de> wrote:
> Blake, if you actually want to make this work in your image, you could
> do this:
>
> Fraction>>printOn: aStream base: base
> | int |
> (int := self integerPart) = 0
> ifTrue: [aStream nextPut: $(.
> numerator printOn: aStream base: base.
> aStream nextPut: $/.
> denominator printOn: aStream base: base.
> aStream nextPut: $)]
> ifFalse: [aStream nextPut: $(.
> int printOn: aStream base: base.
> aStream nextPut: $+.
> self fractionPart printOn: aStream base: base.
> aStream nextPut: $)]
>
> (and delete Fraction>>printOn: which os redundant anyway)
>
> I can see how this would be helpful in debugging if you deal with
> fractions a lot.
That's cool but I'm basically using the Fractions class for quick
double-checks of math with fractions, so I sit down at whatever machine is
handy, pull up Squeak and...
(Not that I'd object to printOn being changed or anything; it's just
overkill.)
More information about the Beginners
mailing list