Ruby
Ruby
• puts()
• print()
• first_name = "Bharath“
• lastName = "Kumar"
• Followed by the underscore or lowercase letter the
next character of a variable can be a number or other
letters, but not symbols.
• _123, rate1 //valid
• #abc, n*ame //invalid variable names.
• Local Variables
• Class Variables
• Instance Variables
• Global Variables
Reserved Words/Keywords in Ruby
• There are certain words that are reserved for
doing specific tasks. These words are known
as keywords and they
have standard, predefined meaning in Ruby.
• These keywords cannot be used for naming
variables or constants in Ruby.
Arrays in Ruby
• An array stores multiple values of the same
data type. Array is similar to range, but the
only difference is that range must represent
continuous sequences.
• Array on the other hand contains collection of
data; it doesn't need to be consecutive
sequence. The real life examples of arrays are:
• For example,
• For example,
• numbers = [1,3,5,7,9]