Method: Tb::Search::State#fetch
- Defined in:
- lib/tb/search.rb
#fetch(k, *rest) ⇒ Object
517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
# File 'lib/tb/search.rb', line 517 def fetch(k, *rest) pairs = self while !pairs.empty? return pairs.val if k == pairs.key pairs = pairs.tail end if block_given? yield k elsif !rest.empty? return rest[0] else raise KeyError, "key not found: #{k}" end end |