Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby

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!

Cheers!