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 trial


Sarah Flynn
Sarah Flynn
4,466 Points

I have copied this code exactly, but it isn't working.

I'm following along with the videos and practicing as I go. I believe I have put exactly the same instructions into my Ruby workspace as in the video I watched, but it doesn't run at all. I get this error message:

NameError: undefined local variable or method 'number2' for main:Object from (irb) 12 from /usr/local/bin/irb:11:in '<main>'

Here's my code:

def get_name(a) print "Enter your name: " return gets.chomp end

name = get_name(a)

puts "Hi #{name}!"

1 Answer

Hi! You just need to remove the 'a', because 'a' isn't defined.

```def get_name() print "Enter your name: " return gets.chomp end

name = get_name()

puts "Hi #{name}!"```

I hope this helps!