class RubyLearning def test_each dirs = Dir.glob('*') dirs.each { |dir| @dirs += ( dir + '\n' )} puts @dirs end end RubyLearning.new.test_each
错误信息
NoMethodError: undefined method `+' for nil:NilClass
method test_each in ruby_learning.rb at line 4
method each in ruby_learning.rb at line 4
method test_each in ruby_learning.rb at line 4
at top level in ruby_learning.rb at line 10
Program exited with code #1 after 0.04 seconds.
本来该提问的,可是积分不够,望Admin手下留情method test_each in ruby_learning.rb at line 4
method each in ruby_learning.rb at line 4
method test_each in ruby_learning.rb at line 4
at top level in ruby_learning.rb at line 10
Program exited with code #1 after 0.04 seconds.