You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classNilClass# Simply returns nil.## Useful for something like:## if some_hash[:a][:b]# # (where some_hash is a hash of hashes)## which would throw a NoMethodError if some_hash didn't have a value for :a.## I haven't had any problems using this yet, but it has the possibility of# causing some problems with libraries that depend on the other behavior.def [](key)nilendend
Example of NilClass#[] defined to see the difference.
some_hash={}ifsome_hash[:a][:b]puts("got in")elseputs("didn't get in")end
The text was updated successfully, but these errors were encountered:
While it would certainly be convenient in many cases, it probably would break a good number of programs too. For this reason I think it has to be rejected.
Example of NilClass#[] defined to see the difference.
The text was updated successfully, but these errors were encountered: