All you need to know to start about Ruby
Ruby is a general purpose language, commonly used in Rails applications.
Ruby is interpreted (does not need a compiler). It is object-oriented and case-sensitive language. Ruby does not require semicolon(:). Variables in Ruby are declared as:
my_number = 25
my_boolean = true
my_string = "Hello"
puts my_numberIt supports simple mathematical operations like: + - * / % **
There are two methods that are used to print on screen: puts and print . print prints content as it is. puts adds a new line to the content. There are no parentheses.
print "Hello There"
puts "How are you?".length is called on a string or string variable. It returns the length if the string.
puts "Your_Name".length.reverse is called on a string or string variable. It returns the string in reverse order. It does not modify the original string.
puts string_variable.reverse.downcase and .upcase is used to return string in all lowercase and all uppercase respectively. Multiple methods can be called in single line, one after the other.
puts string_variable.upcase.reverseSingle line comments are written with hash(#) in the start. Multi-line comments start with =begin and end with =end .
# This is a single line comment
=begin
This is a
multiple line comment
=endLocal variables are written in all small letters separated by underscore. E.g. my_name, simon