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 Case Statement

Marshall Harbin
Marshall Harbin
1,051 Points

Not registering else statement

Hello My code below works, except for if I reply something other than uppercase or reverse, nothing happens. There is no error message, but it just goes back to this line "treehouse:~/workspace$"

Here is the code, anyone know what is wrong? Thanks in advance

print "Enter name: " name = gets.chomp.capitalize!

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

print "Modify your name. Type 'uppercase' or 'reverse': " reply = gets.chomp.downcase

case reply when "reverse" puts name.reverse when "uppercase" puts name.upcase when "both" puts name.reverse.upcase else puts = "Ok, maybe later."

end

1 Answer

Kourosh Raeen
Kourosh Raeen
23,733 Points

The statement

puts = "Ok, maybe later."

should be

puts "Ok, maybe later."