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
#4451
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.compact

Returns a copy of self with all nil elements removed.

array.compact!

Removes nil elements from array. Returns nil if no changes were made.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4452
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.delete_at(index)

Deletes the element at the specified index, returning that element, or nil if the index is out of range.

array.delete_if { |item| block }

Deletes every element of self for which block evaluates to true.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4453
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.each { |item| block }

Calls block once for each element in self, passing that element as a parameter.

array.each_index { |index| block }


Same as Array#each, but passes the index of the element instead of the element itself.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4454
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.first [or] array.first(n)

Returns the first element, or the first n elements, of the array. If the array is empty, the first form returns nil, and the second form returns an empty array.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4455
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.flatten

Returns a new array that is a one-dimensional flattening of this array (recursively).

array.flatten!

Flattens array in place. Returns nil if no modifications were made. (array contains no subarrays.)
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4456
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.hash

Compute a hash-code for array. Two arrays with the same content will have the same hash code

array.include?(obj)

Returns true if obj is present in self, false otherwise.

array.index(obj)

Returns the index of the first object in self that is == to obj. Returns nil if no match is found.
 
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