tutorial net
*********WOOOOOOW *********
We're happy to see you're enjoying our races (already 5 pages viewed today)! You can keep checking out by becoming a member of the tutorial net community. It's free!
You will also be able to keep track of your race progress, practice on exercises, and chat with other members.

Go down
Posts : 207
Join date : 2017-11-11
Age : 28
Location : algeria
View user profilehttp://www.tutorial-net.com

tutorial ruby - Start using variables and simple objects

on Sun Apr 01, 2018 4:12 pm
I take advantage of these first moments of the course with the console to share two small tips that may be useful throughout the course:

to empty the contents of the console, you just have to type Ctrl+ Lon your keyboard (it is a shortcut for the control clear  of the console).  

to exit the IRB, type exit in your console.

In summary :
To run Ruby code directly in your console, you need to use the  Ruby console called IRB (Interactive Ruby)  by typing the following command:

Then type the Ruby command that you want.

A variable is a kind of " box" in which content  can be stored in different forms: a number, a string (or string ) ... and many other forms that you will discover later in this course !

Operator is used =  to store an object in a variable, for example:
cadeau = "bon pour un voyage autour du monde".
It is said that one assigns a value ("good for a journey around the world") to a variable (gift).

Mathematical operations can be performed on variables containing numbers. For example, the age_de_ruby following variable :
age_de_ruby = 2015 - annee_de_naissance_ruby  
will contain the value 20  (and yes, Ruby has all the future ahead of him : D).

Variables containing strings can be grouped using the operator +  : we say we are  concatenating . For example, the message  following variable :
message = "Bravo, tu as reçu un " + cadeau + " !"
will contain the value "Bravo, tu as reçu un bon pour un voyage autour du monde !"
Back to top
Permissions in this forum:
You cannot reply to topics in this forum