Class: Array
Overview
Array extensions
Instance Method Summary collapse
- #_uniq ⇒ Object
-
#reverse_each_with_index ⇒ Object
Runs through the elements form the back with index.
-
#sort_by! ⇒ Array
Sort by array in place.
Instance Method Details
#_uniq ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'opal/fron/core_ext/array.rb', line 24 def _uniq return uniq unless block_given? data = uniq results = [] data.reject do |item| value = yield item next true if results.include? value results << value false end end |
#reverse_each_with_index ⇒ Object
Runs through the elements form the back with index
7 8 9 10 11 |
# File 'opal/fron/core_ext/array.rb', line 7 def reverse_each_with_index (0...length).reverse_each do |i| yield self[i], i end end |
#sort_by! ⇒ Array
Sort by array in place.
18 19 20 21 22 |
# File 'opal/fron/core_ext/array.rb', line 18 def sort_by! sort! do |a, b| yield(a) <=> yield(b) end end |