undefined method `[]=' for nil:NilClass
コード:
a.b.c.d['test'].e['foo']
私の解決策:
puts "got it: #{a.inspect}" if a.nil?
puts "got it: #{a.b.inspect}" if a.b.nil?
puts "got it: #{a.b.c.inspect}" if a.b.c.nil?
生産例外を処理する横。また、開発段階で nil オブジェクトをより速く見つけることも必要です。
(https://stackoverflow.com/questions/9159032/is-there-a-nicer-way-to-write-this-type-of-nil-check)