From: Julian Leviston Date: 2012-09-07T14:51:41+09:00 Subject: Re: Doing math in Ruby This is not simple. Try simpler. Blog: http://random8.zenunit.com/ Twitter: http://twitter.com/random8r Learn: http://sensei.zenunit.com/ New video up now at http://sensei.zenunit.com/ real fastcgi rails deploy process! Check it out now! On 07/09/2012, at 11:52 AM, "Jon M." wrote: > Hello everybody. I am new to Ruby and understand the bare minimum of > basic concepts. I was wondering if there was a way to take the input of > a user (supposedly a mathematical equation) and return the answer. For > example, if I started the Ruby script in my Terminal, is there a way > that I would be able to type in 1+2 and get a returned answer of 3? > Something I tried was: > > puts "Enter Equation" > answervar = gets.chomp > doneans = answervar.to_i > puts doneans > > Yet, all that did was return the first number of the equation. Any help > or advice would be greatly appreciated. Thanks! > > -- > Posted via http://www.ruby-forum.com/. >