Closed raq929 closed 7 years ago
Possibly related to #19?
Use a class instance var? What's your objection? No need to do it this time.
You're correct. The whole example should be waxed per #19. But to illustrate my previous comment:
class Cat
- @@cats_count = 0
+ @cats_count = 0
def initialize(name)
@name = name
- @@cats_count += 1
+ @cats_count += 1
+ # or maybe self.instance_variable_get(:@cats_count) += 1
end
def self.cats_count
- @@cats_count
+ @cats_count
+ # or maybe self.instance_variable_get(:@cats_count)
end
def meow
puts "#{@name} meows"
end
end
I see cat_counter.rb
is gone. Is this closeable, @raq929?
cat_counter.rb
is gone and there are no class variables in repo @@
. This can be closed @jrhorn424.
\o/
Also, yay!
The linter doesn't like this. It thinks I should replace the class var with a class instance var. But I'm teaching class vars.
I don't like having linter errors, but I'm not sure how to avoid this one. Ideas?