fork download
  1. class Foo
  2. attr_accessor :bar
  3.  
  4. def initialize
  5. @bar = [1, 2, 3]
  6. end
  7.  
  8. def baz
  9. if bar.empty?
  10. bar = [4, 5, 6]
  11. end
  12. bar.size
  13. end
  14.  
  15. end
  16.  
  17. a = Foo.new
  18. a.baz
  19.  
Runtime error #stdin #stdout #stderr 0.03s 7460KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog.rb:12:in `baz': undefined method `size' for nil:NilClass (NoMethodError)
	from prog.rb:18:in `<main>'