Enumerables Flashcards
returns true self == object, false otherwise
include?, member?
returns true if all elements meet a specified criterion, false otherwise
all?
returns true if any element meets a specified criterion, false otherwise
any?
returns the count of elements, based on an argument or block criterion, if given
count
returns a new hash containing the counts of each element
tally
return a specified number of leading elements
take
returns a specified number of trailing elements
drop
returns the elements whose values are smallest among the element, as determined by <=> or a given block
min
returns the elements whose values are largest among the elements, as determined by<=> or a given block
max
Returns a 2-element Array containing the smallest and largest elements.
minmax
Returns the smallest element, as determined by the given block.
min_by
Returns the largest element, as determined by the given block.
max_by
Returns an element selected by the block. find, detect
find, detect
Returns elements selected by the block.
find_all, filter, select
Returns the index of an element selected by a given object or block
find_index
Returns elements that are not duplicates.
uniq
Returns the elements, sorted by <=> or the given block.
sort
Returns the elements, sorted by the given block.
sort_by
Returns objects returned by the block.
map, collect
Returns truthy objects returned by the block
filter_map
Returns flattened objects returned by the block.
flat_map, collect_concat
Returns the object formed by combining all elements.
reduce, inject
Returns the sum of the elements, using method +++.
sum
returns a boolean value if any of the object in the enumerable satisfies the given condition, else it returns false.
.any?
returns a boolean value true if all the objects in the enumerable satisfies the given condition, else it returns false.
.all?
returns a boolean value true if none of the objects in the enumerable satisfies the given condition, else it returns false.
.none?