On 17 August 2011 23:57, Henrik Sperre Johansen <[email protected]> wrote: > On 17.08.2011 22:29, Philippe Marschall wrote: >> >> On 17.08.2011 22:17, Stéphane Ducasse wrote: >>> >>> I wrote >>> >>> >>> cull: anArg >>> "Execute the receiver with one or zero argument. >>> >>> [ 1 + 2 ] cull: 5 >>> returns 3 >>> [ :x | 1+ 2 + x] cull: 5 >>> returns 8 >>> " >>> ^numArgs = 0 >>> ifTrue: [self value] >>> ifFalse: [self value: anArg] >>> >> >> So it's like #valueWithPossibleArgument:? > > Almost. > cull: raises error if given blocks with too many args, > valueWithPossibleArgument(s): evaluates with the extra args as nil. >> >> Why do we need two methods >> that do the same thing? > > Because valueWithPossibleArguments was there first, and we can't simply > remove it. > cull is more natural to use in 99.9% of the cases. > > Also, #cull: protocol only goes up to 4 arguments, mirroring #value: > (#cullWithArguments: not being present is mostly an oversight though... ) >
yes yes, cull is cool. no need to provide more arguments :) Also, it is easier to use and remember, because every time i need to use valueWithPossibleBlahblah i always forgetting the right selector and need to lookup the implementation. -- Best regards, Igor Stasenko AKA sig.
