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

Ruby Ruby Operators and Control Structures Ruby Control Structures The Ruby Else Statement

I did the exact same code as the teacher and in my console I don't get name after entering?

This has happened to me before and sometimes I get the same result as the teacher.. Am I doing something wrong?

4 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Even with the code you provided, I'm afraid it's still too little information to pinpoint what the exact problem is here.

But I can give you some suggestions for possible fix:

  1. Make sure that you write the code in the control_structures.rb file, and save the change to file before trying to execute it.
  2. It's quite possible that you're trying to run this ruby file while the Console is in irb environment, that won't work, as this command ruby control_structures.rb is meant to be executed in the Command Line environment. How to tell which mode it's currently on? When the prompt shows irb(main):001:0>, you're in irb mode:x:; treehouse:~/workspace$ == Command line environment:white_check_mark:
  3. Last but not least, if you've confirmed that the previous two points aren't the causes of the problem, then make sure there's a control_structures.rb file in the current directory, otherwise there's nothing for the ruby command to execute. You can list the files in current directory by issuing the ls command.

Hope this info is useful to you.

Post your code so we can help you.

i tried to enter a side by side screenshot of my laptop but it wouldn't work. But here's my code

print " Enter name" name = gets.chomp

if name == "Jason" puts "That's my name, too!" else puts " Hi #{name}!" end

Then I enter in the console - ruby control_structures.rb and it gives me nothing but when the teacher enters it Ruby asks for name: ?????????

Is this in workspaces?

Thanks William. Had a duh moment there.