class Foo attr_accessor :bar def initialize @bar = [1, 2, 3] end def baz if bar.empty? bar = [4, 5, 6] end bar.size end end a = Foo.new a.baz
Standard input is empty
Standard output is empty
prog.rb:12:in `baz': undefined method `size' for nil:NilClass (NoMethodError) from prog.rb:18:in `<main>'