[Newbies] Re: Proper fractions?
Blake
blake at kingdomrpg.com
Fri Jul 27 01:04:55 UTC 2007
On Thu, 26 Jul 2007 18:01:37 -0700, Blake <blake at kingdomrpg.com> 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.)
(Though I admit I put this in one of my images.)
More information about the Beginners
mailing list