Web development Company
Publié le - 797 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. 5 Janv. 2020Hiring the best in terms of Php programmers for your project364 hits
  2. 20 Avril 2018Why our developers are interested in e-commerce too1238 hits
  3. 26 Nov. 2016How is our philosophy to develop ruby on rails?824 hits
  4. 15 Nov. 2016Php and wordpress works perfectly well together !1095 hits
  5. 12 Déc. 2015Let your image everywhere1012 hits
  6. 30 Sept. 2015Why we do think that children should learn IT solutions at school1008 hits
  7. 9 Août 2015Why we pay training to our employees1132 hits