P
Pierre Lebrun
Please forgive the trite nature of this question, I'm new to ruby and OO
programming in general. I'm looking to create a counter that keeps track
of the number of instances created from one class (++ would we access
this from the class or the instace?).
I've made a few lame attempts myself so far but nothing functional
Also, why does ruby return an error for:
Class Bob
attr_reader :count
@count = 0
def initialize
@count += 1
end
end
Cheers!
programming in general. I'm looking to create a counter that keeps track
of the number of instances created from one class (++ would we access
this from the class or the instace?).
I've made a few lame attempts myself so far but nothing functional
Also, why does ruby return an error for:
Class Bob
attr_reader :count
@count = 0
def initialize
@count += 1
end
end
Cheers!