Thread: Ruby on Rails
View Single Post
  #10 (permalink)  
Old 10-09-2007, 03:19 AM
prasannavigneshr prasannavigneshr is offline
D-Web Incredible
 
Join Date: Feb 2007
Posts: 1,321
prasannavigneshr is on a distinguished road
Send a message via MSN to prasannavigneshr
Thumbs up Ruby on Rails

Reading Text


To get started reading text in Ruby, follow these steps:
  1. Enter this code in a new file, gets.rb:
    Quote:
    print “Please enter the temperature: “
    gets
    chomp
    puts “The temperature is #{$_}.”
  2. Save the file and run it.
  3. Ruby displays the prompt Please enter the temperature: and then waits for a response from you:
    Quote:
    C:\rubydev>ruby gets.rb
    Please enter the temperature:
  4. Enter a temperature and press Enter. Ruby reads the text that you have entered, chomps the
    newline character off the end of it, and displays the resulting text:
Quote:
C:\rubydev>ruby gets.rb
Please enter the temperature: 36
The temperature is 36.
__________________
Prasanna Vignesh
MCPD | Web Developer
Reply With Quote