Ruby, Tutorials

Chapter 1: Introduction to Ruby

Hello, Folks. Welcome to my tutorial series on Ruby programming language.

Please read my previous posts Ruby Installation and RVM Commands.

Ruby

  • Developed by Yukihiro Matsumoto in 1993
  • Scripting language
  • Object oriented language
  • Open source
  • Interpreted language
  • Simple and Powerful
  • Clean and Easy Syntax
  • Low learning Curve

Ruby is very simple that a minimalistic program can be written in a line. Let’s begin with a hello world:

puts "Hello World"

The above line of code is enough to print a “Hello World”. Cool!! Isn’t it?

Ruby program file should end with ‘.rb’ extension.

To run a ruby program named ‘helloworld.rb’, open a command terminal window and run – “ruby helloworld.rb”

Interactive Ruby (IRb):

Interactive Ruby provides a shell to experiment with ruby codes. Within the shell, you can run ruby codes and see the results.

To open an IRb shell, type irb in command prompt and an Interactive Ruby session will start. Below is a screenshot of command prompt with an IRb session.

Screenshot from 2017-04-26 14:38:59

Next Step

Hope you have set up a ruby environment and ready for playing with ruby. I have some exercises for you guys:

  • Write a ruby program that prints “Hello World”
  • Write a ruby program that prints the result of 3 + 2

Have Fun!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s