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

Modify the "valid_command?" method to return true when passed the following values: "y", "yes", "Y", or "YES".

answer is : def valid_command?(command) if ( command == "y" ) || ( command == "yes" ) || ( command == "Y" ) || ( command == "YES" ) return true end end

I am getting an error that says "The "YES" command was not valid

4 Answers

Just try refreshing. I just tried it, and it works fine. The only time it didn't work is when I tried the entire method as one line.

I did the following: def valid_command?(command) if (command.downcase == "y") || (command.downcase == "yes") return true end end

you can simply that a bit def valid_command?(command) if (command = "y") || ("yes") || ("Y") || ("YES") return true end end

Can you explain why there are two end's at the end of the method?

One (end) for the method, and one (end) for the if statement inside the method.

def if return end end