Numbers in Smalltalk

John Hinsley jhinsley at telinco.co.uk
Sun Dec 9 22:27:27 UTC 2001


James Stark wrote:
> 
> Hi!
> 
> I have a number in a variable number called:
> 
> (anumber)
> 
> I want to output this to a file... but smalltalk comes up with something
> about "ERROR: anString) when I put nextPutAll.  It does it with strings ok,
> but with numbers it will not output to a file, any suggestions? is a number
> a byte?
> 
> I actually convert from String to Numbers using "anNumber" method.... how do
> you convert the number back to being a string?  since when I convert floats
> to numbers they are fraction... I want to get them back again... how do I do
> that?
> 


(Very) briefly:

9  is a number 
'9' is a string
you could do
 9 asString
which will (do a "print it" on 9) produce '9'

There's lots of stuff on the Swiki (see www.squeak.org for directions
and for links to other sources) which will point you in the right
direction. 

> Any suggestions would be welcome since I am finding it hard to program in
> Smalltalk since it seems to take the pinciple of oo to the extreme!

Others would argue (IMHO with no small justification) that Smalltalk
sets the standards for OO which others have relentlessly diluted.

Cheers

John


-- 
Reputed to be the reason Windows 2000 was nearly a year late, (paid in
shares M$Ds needed the cash and kudos) Netproject's Eddie Bleasdale has
renewed his challenge to virus writers. The first person to infect his
Linux box wins 10,000 pounds.

http://www.silicon.com/bin/bladerunner?30REQEVENT=&REQAUTH=21046&14001REQSUB=REQINT1=48211




More information about the Squeak-dev mailing list