From: Mike Stok Date: 2013-06-24T06:04:24+09:00 Subject: Re: How do I input a variable floating point number into Ruby Programs On 2013-06-23, at 5:03 PM, Mike Stok wrote: > On 2013-06-23, at 2:51 PM, "Michael P F." wrote: > >> I want to input the variable, which changes, from the console and >> evaluate multiple examples without entering the constant multiple times. >> >> -- >> Posted via http://www.ruby-forum.com/. > > Do yo mean something like this (which uses the highline gem to prompt for input and coerce it to the right type): > > #!/usr/bin/env ruby > > require 'rubygems' > require 'highline/import' > > CONST = 28977682.9 > > begin > loop do > num = ask("Enter number: ", Float) > puts CONST * num Oops, that * should be a /. > end > rescue EOFError > puts "Bye!" > end > > __END__ > > Hope this helps, > > Mike > > > -- > > Mike Stok > http://www.stok.ca/~mike/ > > The "`Stok' disclaimers" apply. > > > > > > -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply.