Nil is actually NilClass
If for whatever reason you wanted to modify something inside nil
, the class name is NilClass
🤯 Yes it's very mind blowing, I know 🤯
Example of bad code I couldn't figure out why it wasn't working
class Nil
def to_i
-1
end
end
The fix needed to make it behave as expected
class NilClass
def to_i
-1
end
end
Tweet