Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialfederico enrico
6,143 PointsStuck at this
hello, when I write this code:
def get_name()
print "Enter your name: "
return gets.chomp
end
def greet(name)
puts "Hi #{name}"
if (name == "fede")
puts "Nice name"
end
end
def get_number(number)
print "gimme a number"
return gets.chomp.to_i
end
def divisible_by_3?(number)
return (number % 3 == 0)
end
name = get_name()
greet(name)
number = get_number()
if divisible_by_3?(number)
puts "Your number is divisible by 3"
end
I keep on getting this message in the console:
treehouse:~/workspace$ ruby number.rb
Enter your name: fede
Hi fede
Nice name
number.rb:13:in get_number': wrong number of arguments (0 for 1) (Argum
entError)
from number.rb:24:in
<main>'
2 Answers
Maciej Czuchnowski
36,441 PointsIn this line:
def get_number(number)
You are declaring that every time you call this method, you will pass an argument into it and that this argument will be referred to as number
inside the method.
In this line:
number = get_number()
You are calling the aforementioned method, but you are not passing any value inside the parentheses and it expected one argument.
I think you should just change the definition to this:
def get_number()
federico enrico
6,143 Pointsthanks a lot Maciej!