Ruby (1): The simplest programming language yet

If you have some experience on programming especially based on linux kind operating systems (Ubuntu, Mac OS X, so on.), you will find Ruby easy to get familiar with and very simple to use. This article is just for those who have some programming knowledge or experience such as Java, C#, VB.NET, C, C++ or even Objective-C, assuming that you are somewhat familiar with the concept of OOP and basic idea of programming language.
Ruby is quite not the same as those legendary language like C or java. It is very interactive and simple. If you are using Mac OS X, you already have Ruby development environment. Most of linux OS also include any necessary development tools. – You can find further information on some other many websites that can be found by googling. (i.e. http://www.ruby-lang.org)
I will let you look up those websites for Ruby installation and set-ups. It is as simple as just typing a couple of lines on Terminal if you are on Linux-based-OS, or even you may not need to install in case it is already installed on your operating system.
Firstly, open a terminal and use ‘rib’ commend to get into the Ruby interpreter. You may find it different from other IDE, in fact, this is not IDE at all. However, this is the easiest way to test your code or try out some code quickly.
Basic operators from other languages work almost the same way.
+ – / * (addition, subtraction, multiplication, division)
** (exponent)
% (remainder)
#null type is called “nil” in Ruby.
There are some basic classes that are useful to know.
Integer – integer type
methods: +, -, /, *, %, **, to_s, to_f
Float – float type (decimal)
methods: +, -, /, *, %, **, to_s, to_i
String – text type
methods: capitalise, reverse, length, upcase, to_i, to_f
To use method with a class, it is simple as the following.
“hello”.capitalize
=> “Hello”
(This is “hello” object of String class and the object used ‘captalize’ method like putting ‘.methodName’ in front of the class object.
*To know more about methods of some classes, just use ‘ri’ commend on Terminal window.

If you have some experience on programming especially based on linux kind operating systems (Ubuntu, Mac OS X, so on.), you will find Ruby easy to get familiar with and very simple to use. This article is just for those who have some programming knowledge or experience such as Java, C#, VB.NET, C, C++ or even Objective-C, assuming that you are somewhat familiar with the concept of OOP and basic idea of programming language.
Ruby is quite not the same as those legendary language like C or java. It is very interactive and simple. If you are using Mac OS X, you already have Ruby development environment. Most of linux OS also include any necessary development tools. – You can find further information on some other many websites that can be found by googling. (i.e. http://www.ruby-lang.org)I will let you look up those websites for Ruby installation and set-ups. It is as simple as just typing a couple of lines on Terminal if you are on Linux-based-OS, or even you may not need to install in case it is already installed on your operating system. Firstly, open a terminal and use ‘rib’ commend to get into the Ruby interpreter. You may find it different from other IDE, in fact, this is not IDE at all. However, this is the easiest way to test your code or try out some code quickly.
Basic operators from other languages work almost the same way. + – / * (addition, subtraction, multiplication, division)** (exponent)% (remainder)
#null type is called “nil” in Ruby.
There are some basic classes that are useful to know. Integer – integer type  methods: +, -, /, *, %, **, to_s, to_fFloat – float type (decimal) methods: +, -, /, *, %, **, to_s, to_iString – text type methods: capitalise, reverse, length, upcase, to_i, to_f
To use method with a class, it is simple as the following. “hello”.capitalize=> “Hello”(This is “hello” object of String class and the object used ‘captalize’ method like putting ‘.methodName’ in front of the class object.*To know more about methods of some classes, just use ‘ri’ commend on Terminal window.

** For more basic and detailed information, please refer to the website http://www.ruby-lang.org/en/

(There are some tutorials for beginners)

— coming up next: your own methods and classes

Advertisements