Skip to content

Instantly share code, notes, and snippets.

@Blarsamio
Created April 28, 2025 14:58
Show Gist options
  • Save Blarsamio/bce369c1a21028eec2fb759b81501396 to your computer and use it in GitHub Desktop.
Save Blarsamio/bce369c1a21028eec2fb759b81501396 to your computer and use it in GitHub Desktop.
# 1. Define a method called 'calculate'
# 1a. this method takes 3 parameters, first_number, second_number and the operator
def calculate(first_number, second_number, operator)
# 2. Inside of this method, check which operation the user chose
case operator
when "+" then return first_number + second_number
when "-" then return first_number - second_number
when "*" then return first_number * second_number
when "/" then return first_number.to_f / second_number
else
return nil
end
# 3. Perform the correct calculation and then return the result
end
# # "helicopter"
# def method(parameter)
# # "helicopter"
# puts "This is a #{parameter}"
# end
# helicotper = "helicopter"
# method(helicotper)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment