search for: increment_bar

Displaying 1 result from an estimated 1 matches for "increment_bar".

2008 May 09
2
attr_accessor_with_default funny
...to me. When I tried to create a method in the class which used += on the bare attribute it complained that the attribute was nil D:\Data\Ruby\footy>ruby script\console Loading development environment (Rails 2.0.2) >> class Foo >> attr_accessor_with_default :bar, 0 >> def increment_bar >> bar += 1 >> end >> end => nil >> f = Foo.new => #<Foo:0x37b47d0> >> f.increment_bar NoMethodError: 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.+...