Ruby - Arrays !
An array is an ordered collection of elements that can be of any type. Each element in an array is referred to by an index. Array can have objects like integer, string, float, Fixnum, Hash, Symbol....
An array is an ordered collection of elements that can be of any type. Each element in an array is referred to by an index. Array can have objects like integer, string, float, Fixnum, Hash, Symbol....
Ruby uses the case expression with one or more when conditions. After execution it returns one of the when statement or default else case. case gets.chomp when '1' puts "You have entered 1" whe...
Loop is the process in which set of instructions or block of codes are repeated in a specified number of times under certain condition is satisfied. for, while, do while are example of loops. whil...
if Statement in Ruby if, elsif and else block in Ruby controls decision based on the condition to true/false resulting in the different execution of the code. key = 10 if key > 15 puts 'Key ...
About String String holds and manipulates an arbitrary sequence of bytes which is group of characters. String in ruby is defined using single quote and double quote as: strvar = 'this is string' ...
Getting user input gets keyword is used to get the user input as a string. #!/usr/bin/ruby puts 'what is your name?' name = gets.chomp puts "How are you #{name}" String#chomp method returns st...
puts vs print puts and print both are used to display the result of evaluating Ruby code. Major difference between these two are: puts adds a newline after executing but print does not add new lin...
Having & Group Clause Having is used to restrict the rows affected by the Group By clause as it iis similar to Where clause. Having applies to summarized group records, whereas Where appli...
What is Ruby variables? Variables are like containers used to store information for later use. Values can be stored in the form of Integer, String, Boolean, Float, Decimal, Array, Hashes, etc. Va...
Scope of Ruby variables Global Variable Global Variables can be accessed inside classes and it’s methods. Global variable are available everywhere. It is defined by prefacing the variable nam...