Archive for March, 2008
Posted in March 24th, 2008
Ruby is a dynamic, reflective, general purpose object-oriented programming language. Originating in Japan in the mid 1990s, Ruby was initially developed and designed by Yukihiro “Matz” Matsumoto and combines syntax inspired by Perl with Smalltalk-like object-oriented features.
Ruby supports multiple programming paradigms (including functional, object oriented and imperative), and features a dynamic type system and automatic […]
continue reading.....
Posted in March 24th, 2008
The following code defines a class named Person. In addition to ‘initialize’, the usual constructor to create new objects, it has two methods: one to override the <=> comparison operator (so Array#sort can sort by age) and the other to override the to_s method (so Kernel#puts can format its output). Here, “attr_reader” is an example […]
continue reading.....
Posted in March 24th, 2008
a = “\nThis is a double quoted string\n”
a = %Q{\nThis is a double quoted string\n}
a = <<BLOCK
This is a multi-line double quoted string
BLOCK
a = %/\nThis is a double quoted string\n/
continue reading.....
Posted in March 24th, 2008
Ruby code runs slower than many compiled languages (as is typical for interpreted languages) and other major scripting languages such as Python and Perl. However, in future releases (current revision: 1.9), Ruby will be bytecode compiled to be executed on YARV (Yet Another Ruby VM). Ruby’s current memory footprint for the same operations is higher […]
continue reading.....
Posted in March 24th, 2008
Some features which differ notably from languages such as C or Perl:
Names which begin with a capital letter are treated as constants, so local variables should begin with a lowercase letter.
The sigils $ and @ do not indicate variable data type as in Perl, but rather function as scope resolution operators.
To denote floating point numbers, […]
continue reading.....
Posted in March 24th, 2008
The syntax of Ruby is broadly similar to Perl and Python. Class and method definitions are signaled by keywords. In contrast to Perl, variables are not obligatorily prefixed with a sigil. When used, the sigil changes the semantics of scope of the variable. The most striking difference from C and Perl is that keywords are […]
continue reading.....
Posted in March 24th, 2008
Ruby is object oriented: every data type is an object, including classes and types which many other languages designate as primitives (such as integers, booleans, and “nil”). Every function is a method. Named values (variables) always designate references to objects, not the objects themselves. Ruby supports inheritance with dynamic dispatch, mixins and singleton methods (belonging […]
continue reading.....
Posted in March 24th, 2008
The language was created by Yukihiro Matsumoto, who started working on Ruby on February 24, 1993, and released it to the public in 1995. “Ruby” was named as a gemstone because of a joke within Matsumoto’s circle of friends alluding to the name of the Perl programming language .
As of December 2007, the latest stable […]
continue reading.....