3 ms·
Yes but they already had it for non-assigning uses.
by Dylan16807 1y ago
Yes 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).