Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/matte.rb
Instance Method Summary collapse
-
#select_recursive(&proc) ⇒ Object
like find, but recursive.
- #start_with?(other) ⇒ Boolean
Instance Method Details
#select_recursive(&proc) ⇒ Object
like find, but recursive
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/matte.rb', line 9 def select_recursive &proc results = [] each do |element| if proc.call element results << element end if element.is_a? Array results.push *(element.select_recursive(&proc)) end end results end |
#start_with?(other) ⇒ Boolean
4 5 6 |
# File 'lib/matte.rb', line 4 def start_with? other take(other.length) == other end |