Select returns a new object e g.
Ruby array select.
The second form creates a copy of the array passed as a parameter the array is generated by calling to ary on the parameter.
Methods the original array will be modified.
You can learn about boolean values in ruby by reading this article.
Using select requires a block.
However if you use the select.
Select is a array class method which returns a new array containing all elements of array for which the given block returns a true value.
Up until now all the methods we ve seen run essentially independent operations on each element of our array or hash.
If no block is given.
The find all method is an alias for select but there is no find all.
Returns a new array containing all elements of ary for which the given block returns a true value.
Next let s look at how to sort the values of an array.
When a size and an optional default are sent an array is created with size copies of default take notice that all elements will reference the same object default.
Select and reject both return a new array leaving the original array unchanged.
Returns a new array.
Ruby latest stable v2 5 5 0 notes class.