# Get two numbers from STDIN, separated by a newline, and output the result number1 = gets number2 = gets puts number1.to_i + number2.to_i ## run with: $ ruby a_plus_b.rb ## or: $ echo -e "1\n2" | ruby a_plus_b.rb