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 Logical Operators The Or (||) Operator

What's wrong!

What is wrong with my code?

ruby.rb
def valid_command?(command)
  if (command == y) || (command == yes) || (command == Y) || (command == YES)
    valid_command? = "true"
end

... other than I forget the end after if!

4 Answers

Colin Marshall
Colin Marshall
32,861 Points

Your commands should be strings. Also, you are returning a string containing the word "true" when you should be returning a boolean of true.

Kevin Mulhern
Kevin Mulhern
20,374 Points

You need to enclose your yes values in quotes to make them strings, for example:

if (command == 'y')

How to set boolean!

Colin Marshall
Colin Marshall
32,861 Points

You just need to put the word true with no quotes around it.

return true

Thanks!