I am trying to store an integer in x or y that gets returned as a string:
def add(a, b) puts "Adding #{a} + #{b}" a + b end def sub(a, b) puts "subtracting #{a} - #{b}" a - b end def mult(a, b) puts "multiplying #{a} * #{b}" a * b end def div(a, b) puts "dividing #{a} / #{b}" a / b end x = STDIN.gets.chomp y = STDIN.gets.chomp puts add(x,y) The response that I get from the program is:
23 43 Adding 23 + 43 2343
getsONLY returns a string. It has no concept of anything but a string, nor does the console, whichgetsreads from by default. It's up to you to make that value be something else.