Sha256: 96e09be3c0f3aa1016685868655e65ab869298e3213ca2f7fc0ee524a95326b0
Contents?: true
Size: 658 Bytes
Versions: 3
Compression:
Stored size: 658 Bytes
Contents
require 'hamster' module Rupture class HashMap < Hamster::Hash include Map def as_map self end def self.empty @empty ||= HashMap.new end end end class Hash include Rupture::Map def as_map F.hash_map(self) end alias ~ as_map def assoc!(*vals) vals.each_slice(2) do |k,v| self[k] = v end self end def update!(key, fn = nil, *args, &block) self[key] = if fn fn.call(self[key], *args, &block) else yield(self[key]) end self end def update_each!(keys, *args, &block) keys.each do |key| update!(key, *args, &block) end self end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rupture-0.3.0 | lib/rupture/hash_map.rb |
rupture-0.2.1 | lib/rupture/hash_map.rb |
rupture-0.2.0 | lib/rupture/hash_map.rb |