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

I'm having trouble and don't understand what this question is asking me. Can someone please explain what's wrong?

I could definitely use some pointers on "Modifying" a method as well.

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

end

2 Answers

Justin Horner
STAFF
Justin Horner
Treehouse Guest Teacher

Hello Rod,

The challenge is asking you to make the function return yes if the command is equal to one of the provided strings. The first problem with your code is you are returning yes only if command is equal to all of the strings because you're using AND (&&) instead of OR (||). The command argument can only be one of these values, it cannot be all of them.

The other problem is you are not wrapping the condition values with quotations to make them strings in Ruby. The end result should look something like this.

  if command == 'yes' || command == 'y'
    return true
  end

I hope this helps.

I've still gotten an error in the syntax. its suppose to return true for the "y" & "yes" in all cases!