Jan. 4, 2015
10:27 p.m.
Hi guys, Iâve started to use this little one: Object>>ifNilOrEmpty: aBlock self ifNil: [ ^ aBlock value ]. (self isCollection and: [ self isEmpty ]) ifTrue: [ ^ aBlock value ]. ^ self. It allows you to do the widely known JavaScript one-liner: var stuff = this.thing || âsome default value for when this.thing is undefined, null or an empty stringâ. but in smalltalk in this way: stuff := self thing ifNilOrEmpty: [ âsome default value for when self thing is nil or an empty stringâ ] simple thing feels practical and nice :)