Techie July 2022
1 . fetch()
Returns the element at offset index.
2 . filter!
Calls the block, if given with each element of array then removes from array those elements for which the block returns false or nil.
3 . filter
Calls the block, if given, with each element of array then returns a new Array containing those elements of the array for which the block returns a truthy value.
4 . fill()
Replaces specified elements in the array with specified objects then returns the array.
5 . flatten()
Returns a new Array that is a recursive flattening of the array. Each non-Array element is unchanged. Each Array is replaced by its individual elements. With non-negative Integer argument level, flattens recursively through level levels
6 . flatten!()
Replaces each nested array in the array with the elements from that array; returns the array if any changes, nil otherwise. With non-negative Integer argument level, flattens recursively through level levels.
7 . find_index()
Returns the index of a specified element. When argument object is given but no block, returns the index of the first element element for which object == element.
8 . first()
Returns elements from the array; does not modify the array. When no argument is given, returns the first element. When non-negative Integer argument n is given, returns the first n elements in a new Array.
9 . find
Returns the first element for which the block returns a truthy value. With a block given, calls the block with successive elements of the collection then returns the first element for which the block returns a truthy value.
10 . find_all
Returns an array containing elements selected by the block. With a block given, calls the block with successive elements then returns an array of those elements for which the block returns a truthy value.
11 . filter_map
Returns an array containing truthy elements returned by the block. With a block given, calls the block with successive elements then returns an array containing each truthy value returned by the block.
12 . flat_map
Returns an array of flattened objects returned by the block. With a block given, calls the block with successive elements; returns a flattened array of objects returned by the block.
13 . freeze
Prevents further modifications to obj. A FrozenError will be raised if modification is attempted. There is no way to unfreeze a frozen object.
14 . frozen?
Returns the freeze status of object.
15 . grep
Returns an array of objects based elements of the array that match the given pattern.
With no block given, returns an array containing each element for which pattern === element is true.
With a block given, calls the block with each matching element and returns an array containing each object returned by the block.
16 . grep_v
Returns an array of objects based on elements of self that don’t match the given pattern.
With no block given, returns an array containing each element for which pattern === element is false.
With a block given, calls the block with each non-matching element and returns an array containing each object returned by the block.
17 . group_by
With a block given returns a hash:
- Each key is a return value from the block.
- Each value is an array of those elements for which the block returned that key.
18 . hash
Returns the integer hash value for the array.
19 . include?
Returns true if for some index i in the array, object == array[i]; otherwise false.
20 . intersection
Returns a new Array containing each element found both in the array and in all of the given Arrays other_arrays; duplicates are omitted; items are compared using eql?
21 . intersect?
Returns true if the array and other_ary have at least one element in common, otherwise returns false.
22 . insert
Inserts given objects before or after the element at Integer index offset; returns the array.
When index is non-negative, inserts all given objects before the element at offset index. When index is negative, inserts all given objects after the element at offset index+self.size.
Extends the array if index is beyond the array (index >= array.size).
23 . index
This method is an alias for Array#find_index. When argument object is given but no block, returns the index of the first element element for which object == element.
When both argument object and a block are given, calls the block with each successive element then returns the index of the first element for which the block returns a truthy value.
24 . inspect
This is an alias for to_s method. Returns the new String formed by calling method inspect on each array element.
25 . inject
This is an alias for the reduce method. It returns an object formed from operands via either:
- A method named by symbol.
- A block to which each operand is passed.
Inject takes the first element of the array and uses it as the initial value for sum (if an argument is passed, it becomes the initial value). Then it takes the next element and adds them together. The the result becomes the initial sum value which is then added to the next element in the array until all elements have passed through the block.
26 . itself
Returns the receiver.
27 . instance_of?
Returns true if object is an instance of the given class.
28 . is_a?
This method is an alias for kind_of?.
Thanks for reading, see you in the next one!