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 <b...@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@lists.squeakfoundation.org > http://lists.squeakfoundation.org/mailman/listinfo/beginners >
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners