Skip to content

Instantly share code, notes, and snippets.

@jkaihsu
Created March 7, 2013 08:13
Show Gist options
  • Select an option

  • Save jkaihsu/5106377 to your computer and use it in GitHub Desktop.

Select an option

Save jkaihsu/5106377 to your computer and use it in GitHub Desktop.
Define four methods which correspond to the four basic arithmetic operations: add, subtract, multiply, divide.They should accept either integers or floating point numbers as input. divide should perform floating point division.
def add(x,y)
x + y
end
def subtract(x,y)
x - y
end
def multiply(x,y)
x * y
end
def divide(x,y)
x.to_f / y.to_f
end
@rcasanova201
Copy link
Copy Markdown

Thank you! I have spent hours trying to solve this with actual integers, whoops:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment