vik-y
10/31/2015 - 6:34 AM

Some important things about ruby

Some important things about ruby

#!/usr/bin/ruby

def sample (*test)
   puts "The number of parameters is #{test.length}"
   for i in 0...test.length
      puts "The parameters are #{test[i]}"
   end
end
sample "Zara", "6", "F"
sample "Mac", "36", "M", "MCA"

# We mentioned only one argument while defining the function
# but we can pass multiple arguments
# they will be treated as an array 

# Some interesting things related to classes in ruby 

class Accounts
   def reading_charge
   end
   def Accounts.return_date
   end
end

Accounts.return_date 
# access method return date without making an object of type Accounts 


#yield statement in ruby