Ah Henry but you are making the code to know if it’s a collection or not, I talking about making the code specifically to ignore that.
Why that would lead to "bad code"? can you elaborate or put examples instead of adjectives? > On Jan 5, 2015, at 1:02 PM, Henrik Johansen <[email protected]> > wrote: > > No, I'm talking about exactly what I quoted, implementing ifNilOrEmpty: on > just UndefinedObject/Collection, but not Object. > Doing that is not about indoctrinating, but preventing bad code resulting > from using the same variable to hold non-polymorphic objects. > >> >> Whatever the case does your idea pass this test? >> >> testIfNilOrEmpty >> >> | stuff thing | >> >> stuff := nil. >> >> self assert: stuff equals: nil. >> self assert: thing equals: nil. >> thing := stuff ifNilOrEmpty: [ 42 ]. >> self assert: thing equals: 42. >> >> stuff := 1984. >> thing := stuff ifNilOrEmpty: [ 42 ]. >> >> self deny: thing = nil. >> self assert: thing equals: 1984. >> self deny: thing = 42. > > Of course, since my idea was to use ifNil: when the variable you are dealing > with is not Collections.
