3 ms·
So like ruby's '&.' null safe chaining
by drzaiusx11 1y ago
So like ruby's '&.' null safe chaining
- Dylan16807 1y agoYes but they already had it for non-assigning uses.
- dominicrose 1y agoRuby is a true OOP programming language unlike all the ones who just pretend to be. It's similar to Smalltalk in many regards. In Ruby only nil and false are falsy (and they are both objects with their respective classes) so for non-boolean types we can just use ||=. It works with undefined variables as well. This strong typing also means we can use the = operator in if statements. Compare that with PHP where the "0" string is falsy and where even the array has no class (so no methods).