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 am afraid that I have not understood the way to modify concerning 'y', 'Y', and 'yes' 'YES'.

I am not even sure how to ask about a problem that I am not doing right. just general help as to why my answer is not working properly.

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


end

2 Answers

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

In Ruby, command =='y','Y' and command == 'YES','yes' aren't legal syntax.

the simplest way to solve this problem is

def valid_command?(command)
  command == 'y' || 'Y' || 'yes' || 'YES'
end

Gucci mayne........I was trying to do it as instructed by the ruby tutorial hosted by Jason Seifer......

William Li
William Li
Courses Plus Student 26,868 Points

I see, let me watch how Jason did during the video.

William Li
William Li
Courses Plus Student 26,868 Points

okay, I believe this is the reasonable solution of the challenge based on the materials presented during the video lecture.

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

To be honest I did it like this the first time although It reads syntax errors. its weird...it did that with the last challenge with the operators using &&....mystery