Hi! I perfectly understand the purpose of this method "??â Although I do not think this will seriously impact the quality of the code being produced, I still believe it will not help making code of a better quality. Check for the nil value should be banned in my opinion. There are well-known techniques to not have to use it (e.g., Null-object pattern). Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
On May 20, 2015, at 3:19 PM, Aliaksei Syrel <alex.syrel@gmail.com> wrote:
Hi,
Null coalesce operator - returns the first not nil operand. http://en.wikipedia.org/wiki/Null_coalescing_operator <http://en.wikipedia.org/wiki/Null_coalescing_operator>
Adding one simple method to an Object:
?? anObject ^ self
and to UndefinedObject:
?? anObject ^ anObject
could allow us to write:
default1 := nil. default2 := nil. default3 := 'foo'. default4 := 'don''t care'. config := default1 ?? default2 ?? default3 ?? default4.
=> 'foo'
I know you don't like to add new methods to an object, but still :)