Posts

Showing posts from 2007

A Simple introduction to Ruby

Image
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 you

The Ant and the Grasshopper

The Ant and the Grasshopper The Classic Old Version The Ant works hard in the withering heat all summer building its house and laying up supplies for the winter. The Grasshopper thinks the Ant is a fool and laughs & dances & plays the summer away. Come winter, the Ant is warm and well fed. The Grasshopper has no food or shelter so he dies out in the cold. Modern Version The Ant works hard in the withering heat all summer building its house and laying up supplies for the winter. The Grasshopper thinks the Ant's a fool and laughs & dances & plays the summer away. Come winter, the shivering Grasshopper calls a press conference and demands to know why the Ant should be allowed to be warm and well fed while others are cold and starving. NDTV, BBC, CNN show up to provide pictures of the shivering Grasshopper next to a video of the Ant in his comfortable home with a table filled with food. The World is stunned by the sharp contrast. How can this be that this poor Grassho