我想了解如何在 Ruby 1.9 中重现以下错误:
NoMethodError (undefined method `[]' for nil:NilClass):
这是我自己的兴趣。以下对我不起作用:
a = nil
a[:key]
它产生以下错误:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]