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 trialDaniel Ahmadizadeh
1,979 PointsWhy is the "command" being set to == y and not the "valid_command?"?
Thanks!
def valid_command?(command)
if (command == "y") || (valid_command? == "yes") || (valid_command? == "Y") || (valid_command? == "YES")
return "true"
end
end
1 Answer
Francisco Ruiz
14,213 PointsHi Darian
command
is the parameter being passed into the valid_command?
method, so all the logic operations, i.e. if statments, should be run on the command
parameter. So if somewhere else in the code, the method was called like valid_command?("yes")
then "yes" would get passed in via the command
parameter and then you would compare that against "Y", "yes", etc.
You would end up with the if statement looking like this:
if (command == "y") || (command == "yes") || (command == "Y") || (command == "YES")
return true
end
Daniel Ahmadizadeh
1,979 PointsDaniel Ahmadizadeh
1,979 PointsThank you so much Francisco Ruiz ! :)
Francisco Ruiz
14,213 PointsFrancisco Ruiz
14,213 PointsYou're welcome!