More Ruby code is available in form of sample algorithm implementations in articles: * Binary search * Exponentiating by squaring * Linear search |
Ruby language features:
Ruby is purely object-oriented: every bit of data is an object, even basic types. Every function is a method. This is similar to Smalltalk but unlike Java and Python.
The language was created by [Yukihiro Matsumoto]? on February 24, 1993. The current stable version is 1.6.5 (25-09-2001). Note that the name is not an acronym--it is actually a pun on Perl.
Sample Ruby code:
string = "Hello world" # assign "Hello world" string to variable 'string' another_string = string.gsub(" ", ", ") # substritute all " " to ", " in variable 'string' and put result into variable 'another_string' another_string += "!\n" # append "!\n" ("\n" is newline character) to variable 'another_string' print another_string # print variable 'another_string'
More Ruby code is available in form of sample algorithm implementations in articles: