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 trialRahul Nayak
1,221 PointsError while running hello.rb
So here is my code which I tried running: name="Rahul" puts "Hello" puts name
I have written the above code in a file named hello.rb and here is the error output I received :
treehouse:~/workspace$ irb
irb(main):001:0> ruby hello.rb
NameError: undefined local variable or method hello' for main:Object
from (irb):1
from /usr/local/bin/irb:11:in
<main>'
Where am I going wrong ?
4 Answers
Donald Brunais
8,895 PointsYou don't want to enter irb first. You can either do irb hello.rb or ruby hello.rb in the commend line.
johnathan smith
2,569 PointsAll you need to do is enter ruby hello.rb. No need to enter IRB. The reason you are receiving the error message is because you are running something from IRB and what you are running has not been defined.
Burhan L
Front End Web Development Techdegree Student 4,069 PointsHi rahul, so this is where you are going wrong: '''puts "Hello" puts name'''
1) you have 2 puts when you only need 1 puts to print Hello and your name 2) in order to print the Hello string and the variable name you need to concatenate both with a + sign
make sense?
Burhan L
Front End Web Development Techdegree Student 4,069 PointsRahul, Donald is right on with the issue here. Follow this step
Rahul Nayak
1,221 PointsRahul Nayak
1,221 PointsThanks a lot. And I was wondering if I am that stupid that even the simplest of code is giving me an error!!