Today, in this write-up, let us see some basic concepts of Ruby language. This tutorial will help you learn the language easily.
What is Ruby?
It is a dynamic, object-oriented, general-purpose programming language. Now, let’s create our first program - the classic “Hello World” program.
For this, we will use the built-in “puts” method.
Another method that can be used to display the output on the screen is “print”.
The following code displays the same output as earlier except that the “puts” automatically adds a new line after the output, while “print” does not.
Comments
Comments are lines of annotation within Ruby code that are ignored at the program runtime. It uses a symbol of hashtag (#) for single-line comment.
For multiple-lines of comments, we use the “=begin” and “=end” keywords.
Variable
To insert the value of a variable into a double quote string, we use the “#” symbol and curly brackets with the variables name. Here, age is variable and 42 is the value of the variable.
Constants
Variables beginning with a capital letter and whose value, once assigned, can’t be changed are known as constants.
In the above example, the value has already been assigned for the constant variable. If we try to change the value of the variable, it will throw a warning or an error to the user.
Exponent Operator
The “**” symbol represents the exponent operator for raising a number to a power to perform exponentiation.





Karthick PoonkodiPosted Jan 8, 2019, 10:21 PM
keep doing..
Karthick PoonkodiPosted Jan 8, 2019, 10:21 PM
good buddy.