help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Number oddity


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] Number oddity
Date: Tue, 23 Aug 2005 10:11:17 +0200
User-agent: Mozilla Thunderbird 0.9 (Macintosh/20041103)


!Number class methodsFor: 'converting'!

asNumber
  "Let someone ask for a number as a number"
  ^self
!

...or has this already been done?
Well, indeed it's already there in 2.2 :-)

But your method should look like
!Number methodsFor: 'converting'!

because it is not a class method.

You can test whether it is implemented with

   Number canUnderstand: #asNumber

because #respondsTo: checks if the object knows about a message, while #canUnderstand: checks whether the *instances* of the objects can answer it. So an alternative would be (not that it makes much sense...)

   Number new respondsTo: #asNumber

Regards,

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]