Web development Company
Publié le - 490 hits -

Ruby for the start up, our explanation

This short tutorial should take no more than twenty minutes of your time. It assumes that you have already installed Ruby; If not, you are warmly advised to do so before continuing your reading.

Interactive Ruby

A first approach of Ruby, the simplest, is to use IRB in a terminal:
- if you are using Mac OS X, open a Terminal and type irb, then press [enter];
- if you are on Linux, open a console and type irb, then press [enter];
- If you are using Windows, launch Interactive Ruby (IRB) in the Ruby section of the Start> Applications menu.
IRB allows you to write and interpret Ruby without having to save a file and then execute it. Here, IRB is launched. And now ?

Type this: "Hello World" and press enter to confirm (you will need to do that after each new line).

What has just happened ? Do we just write the shortest ever Hello World program? Not quite ... but almost. The second line, starting with the sign =>, is how IRB informs us of the result of the last expression evaluated. If we really want to write "Hello World", it takes a little more: do you know the "puts" and "nil" commands?

  • "puts" is the basic command to write something with Ruby. And "nil", what IRB presents us, what is it? The result of our phrase "puts" "Hello World", of course ! In fact, "puts" always returns "nil", which is, for Ruby and soon, for you, total lack of value. And so now, Ruby is a little clearer for you ?

Modules, or how to group the code by thematic

What is called in Ruby a module? A module is provided to you automatically (it is part of the standard library, which groups the modules of general interest). The modules have two major roles to play within Ruby. The first of these roles is to group together methods (often referred to as "functions" in other languages). For more information, contact our specialist ruby!

Post your comments here

Les publications similaires de "Our Philosophy"

  1. 20 Avril 2018Why our developers are interested in e-commerce too810 hits
  2. 26 Nov. 2016How is our philosophy to develop ruby on rails?556 hits
  3. 15 Nov. 2016Php and wordpress works perfectly well together !645 hits
  4. 12 Déc. 2015Let your image everywhere700 hits
  5. 30 Sept. 2015Why we do think that children should learn IT solutions at school696 hits
  6. 9 Août 2015Why we pay training to our employees748 hits