Attempting to learn Ruby as my first programming language. I was understanding everything fine to this point, but I am drawing a blank at this exercise and not sure where to even get started with this and could use some help.
9: Introducing || operator
Similar to the logical and operator &&, we have a logical or operator ||. The character | is located right above your enter key on the keyboard and is called a pipe. Similar to double ampersand, this one is also commonly referred to as double pipe. The || operator is used if any of the conditions can be true. For example - if number == 1 || number == 3 returns true if number is either 1 or 3. Simple right? Implement a method dinner_choice as per the instructions in the code editor.
This function should return:
- "steak" if celebrity is "brad pitt" or "angelina jolie"
- "italian" if celebrity is "ashton kutcher" or "demi moore"
- "french" if celebrity is none of the above
This is my attempt.
def dinner_choice(celebrity)
return "steak" if celebrity == "brad pitt" || celebrity == "angelina jolie"
return "italian" if celebrity == "ashton kutcher" || celebrity == "demi moore"
else return "french"
end
end