Method: Array#filter
- Defined in:
- lib/hdb/hodb.rb
#filter(fields) ⇒ Object
the follow function didn’t use return a table that contains only fields table = [b:2, c:3, b:5, c:6] table.filter([:a, :c]) => [c:3, c:6]
11 12 13 14 15 16 17 18 19 |
# File 'lib/hdb/hodb.rb', line 11 def filter(fields) result = [] self.each do |row| result << row.select { |key, value| fields.include?(key) } end return result end |