Yes, #ifNil: is almost the same (except the #value): |default1 default2 default3 default4 | default1 := nil. default2 := nil. default3 := 'foo'. default4 := 'don''t care'. default1 ifNil: [ default2 ifNil: [ default3 ifNil: [ default4 ] ] ]
=> 'foo' > On 20 May 2015, at 21:38, Damien Pollet <[email protected]> wrote: > > …ifNone: is a nice idiom, but not always available (in which case, we should > think about introducing it) > > ?? is basically an infix but eager version of #ifNil:, IMHO a pragmatic thing > to have; could be quite handy. > My only fear is that it could encourage the use of nil instead of proper Null > Objects… and here we start bikeshedding > > On 20 May 2015 at 21:31, Sergio Fedi <[email protected]> wrote: > > In my experience those situations end up been handled by collections, > detect:ifNone: which even handles the case when all defaults are nil. > > But maybe that idiom is very common in another situations. > > > > -- > Damien Pollet > type less, do more [ | ] http://people.untyped.org/damien.pollet
