The syntax of the code you provided is incorrect. The correct syntax for defining a method in Ruby would be as follows:
main.rb48 chars4 lines
In this corrected code snippet, we define a method called ticket_price
that takes an age
parameter. The method uses a ternary operator ?:
to determine the ticket price based on the age. If the age is greater than or equal to 60, the price will be 10; otherwise, it will be 15.
Remember to always use parentheses when defining method parameters in Ruby, and make sure the expression inside the ternary operator evaluates to a boolean to correctly determine the ticket price.
gistlibby LogSnag