Sign up or Sign in | Share
 
ClearMyBench
Welcome, Guest
Please Login or Register.    Lost Password?
Re:Ruby basics (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:Ruby basics
#4439
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
We can also use a block with new, populating each element with what the block evaluates to.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4440
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
The Kernel module available in core Ruby, has an Array method, which only accepts a single argument.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4441
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
Array Built-in Methods:

We need to have an instance of Array object to call a Array method.

As we have seen, following is the way to create an instance of Array object:

Array.rray Built-in Methods:

We need to have an instance of Array object to call a Array method.

As we have seen, following is the way to create an instance of Array object:

Array.[](...) [or] Array[...] [or] [...]
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4442
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
This is the way we create an instance of Array object:

Array.[](...) [or] Array[...] [or] [...]


This will returns a new array populated with the given objects. Nowhis is the way we create an instance of Array object:

Array.[](...) [or] Array[...] [or] [...]


This will returns a new array populated with the given objects. Now using created object we can call any available instance methods
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4443
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
Lets discuss some of the public array methods ( Assuming array is an array object )


array & other_array

Returns a new array containing elements common to the two arrays, with no duplicates.

array * int [or] array * str

Returns a new array built by concatenating the int copies of self. With a String argument, equivalent to self.join(str).
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4444
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
array + other_array

Returns a new array built by concatenating the two arrays together to produce a third array.


array . other_array

Returns a new array that is a copy of the original array, removing any items that also appear in other_array
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
get the latest posts directly to your desktop
logo footer   Copyright 2009 - 2013 HotRecruiter.Com - All Rights Reserved