Wrong number of arguments - Twice the @ (9/20)


#1

Having trouble with this lesson, I keep getting wrong number of arguments and unsure what is wrong with my code. Can someone please take a look?

class Person
@@people_count = 0
end

def initialize(name)
@name = name
@@people_count += 1
end

def self.number_of_instances
return @@people_count
end

matz = Person.new("Yukihiro")
dhh = Person.new("David")

puts "Number of Person instances: #{Person.number_of_instances}"


#2

I had the same problem until I changed Line 8 to

"@@people_count = @@people_count + 1"


#3

What yc736 typed worked for me.


#4

Got the same issues but then simply did a reset of the code, rewrote the exact same thing and it worked. Stupid bug in code academy.


#5

has anybody had success I'm almost done with Ruby but I'm missing this lesson. no matter what i put it returns "wrong number of arguments (1 for 0)

please help me with the answer to pass this


#6

Hi there, just did after several trials, I think there's a bug indeed.

I've tried and saved/test the code after each step to get it to work finally

class Person
# Set your class variable to 0 on line 3
@@people_count = 0

def initialize(name)
@name = name
# Increment your class variable on line 8
@@people_count += 1
end

def self.number_of_instances
# Return your class variable on line 13
return @@people_count
end
end

matz = Person.new("Yukihiro")
dhh = Person.new("David")

puts "Number of Person instances: #{Person.number_of_instances}"