Method: Multimap#key
- Defined in:
- lib/multimap.rb
#key(value) ⇒ Object Also known as: index
Search a pair of key and value from self such that
the value is equal to the argument value.
If two or keys are matched, returns one of them.
If no key is matched, returns nil.
selfから値がvalueであるような要素を
検索し、それに対応するキーを返します。該当するキーが複数存在する場合、
そのうちの1つを返します。該当するキーが存在しなければ
nilを返します。
354 355 356 357 358 359 |
# File 'lib/multimap.rb', line 354 def key(value) self.each_pair_with do |key, a_value, count| return key if value == a_value end nil end |