Method: Hash.with_keys
- Defined in:
- lib/amp/support/support.rb
.with_keys(iterable, value = true) ⇒ Hash
Given a list of key names, and a specified value, we create a hash with those keys all equal to value. Useful for making true/false tables with speedy lookup.
579 580 581 582 583 584 |
# File 'lib/amp/support/support.rb', line 579 def self.with_keys(iterable, value=true) # we try to be functional when it doesn't fuck us over # here, the list of keys will never be ridiculous # so we go fuctional iterable.inject({}) {|h, k| h[k] = value; h } end |