1
2
3
puts "What is your name????"
myname = gets.chomp
puts "Your name is #{myname }!"

Let us save this code in a text file first. Preferred extension is .rb but no issues even if no extension provided.

Now on command prompt use this command to execute.

ruby test.rb

This should ask you your name and display your name again if ruby-on-rails installed. It will be something like this:

D:\testruby>ruby test.rg
What is your name????
praveen
Your name is praveen!
 
D:\testruby>
VN:F [1.1.6_502]
Rating: 0.0/5 (0 votes cast)
Share:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • DotNetKicks
  • LinkedIn
  • Live
  • MySpace
  • StumbleUpon
  • Technorati

Related posts:

  1. Ruby program to find largest of two numbers
  2. My first JSP program
  3. Extreme beginner’s LINQ sample in VB.NET
  4. My name is 0×5052415645454e in SQL ;)
  5. Windows7 God Mode