#1 (Almost) Everything is true
#2 All objects could be nil
- Every value is
- The number zero is
true in Ruby.
- Use the
nil? method to differentiate between
#4 Constants are mutable
nil objects into the expected type (eg use
Hash#compact removes all nil elements.
Hash#dig returns nil if any intermediate step is nil.
- Always freeze constants to prevent them form being mutated (eg
TIMEOUT = 5.freeze).
#7 Different behaviours of
- When you override a method from inheritance hierarchy the
super keyword can be used to call the overriden method.
super with no arguments and parentheses is equivalent to passing it all of the arguments that were given to the enclosing method.
- If you want to use
super without passing the overriden method any arguments, you must use empty parentheses (eg
Press h to open a hovercard with more details.