Re:Ruby gaining a safe navigation operator: '.?'
by uxp on Monday October 26, 2015 @06:00PM
(#10454800)
This is entirely incorrect.
nil is a pointer to the value 0, and in C there is only one value that evaluates to a logical false, which is 0. Invoking a method on nil returns 0. This itself alleviates the kind of nil-check-chains discussed in this thread:
nil is a pointer to the value 0, and in C there is only one value that evaluates to a logical false, which is 0. Invoking a method on nil returns 0. This itself alleviates the kind of nil-check-chains discussed in this thread:
if user.profile.name is nil, then that expression evaluates to the value 0, which as we discovered, is the _only value that evaluates to false in C_