A Simple introduction to Ruby

A Simple introduction to Ruby

Hi in this simple introduction i want to give you some very brief idea on Ruby. I am going to write some very simple program here and give the description of them. The peoples who are new to ruby or just want to learn something about ruby they will get the feel of this dynamic language in here.

Simple Hello (first.rb)
Lets start with a simple hello world program. The code is given bellow

puts "Hello World"

Now this is the very simple typical hello world program in ruby. Write this lines into a text file using your favourite editor. And then save it. Run this program by typing the following command in your command prompt

ruby first.rb

Now fig 1 show the screenshot of the ruby program

Fig 1 : The screenshot showing the execution of our typical hello world program

Make it a bit interactive (second.rb)

Now let us write a bit more interactive program out of ruby. Lets say a program which will take your name and will say hello to you.Bellow is the listing of the program

print "Hi please enter your name : "

name=gets
puts "Hello #{name}"

Now follow the same process you followed in the first program to write and execute this program

Fig 2 : A simple interactive program in ruby


Comments

Anonymous said…
WOW it is great. Easy and effective. Thanks for wonderful blog.

Popular posts from this blog

Configure Netbeans For Android development

Configure Netbeans for Apache TomEE and OpenJPA

Configuring CI pipeline in Jenkins for PHP projects