[Newbies] Adding method to Smallinteger class
David Mitchell
david.mitchell at gmail.com
Sat Apr 24 12:26:36 UTC 2010
OK, Bert is having a little fun. Certainly good to learn that self is the
default value.
But I wouldn't think of this as idiomatic smalltalk style.
I would prefer to follow "Interesting Return Value" [Beck]. I also factored
out the return, since that is the same in both branches.
larger: anInteger
^ self > anInteger
ifTrue: [self]
ifFalse: [anInteger]
On Fri, Apr 23, 2010 at 4:39 PM, Bert Freudenberg <bert at freudenbergs.de>wrote:
> On 23.04.2010, at 23:19, Herbert König wrote:
> >
> > Hi Randal,
> >
> >
> > RLS> larger: anInteger
> > RLS> ^self max: anInteger
> > RLS> Code re-use, bay-bee.
> >
> > true but couldn't resist to throw blocks at a newbie myself :-))
>
> Sure, but two blocks are just too scary ;)
> Much more fun to figure out why this works:
>
> larger: anInteger
> anInteger > self ifTrue: [^ anInteger]
>
> - Bert -
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20100424/03f9aa3b/attachment.htm
More information about the Beginners
mailing list