Sha256: 59bfa841bd4c92b0ddb8943312317fbbb512381bd78970b1874c1e4a8a1714ed
Contents?: true
Size: 551 Bytes
Versions: 3
Compression:
Stored size: 551 Bytes
Contents
class Hash # Add slicing to element assignment operator. # # require "facet/hash/slice-op" # # h = {:a=>1, :b=>2, :c=>3} # # h[:a] = 9 #=> 9 # h #=> {:a=>9, :b=>2, :c=>3} # # h[:a, :c] = [10,11] #=> [10,11] # h #=> {:a=>10, :b=>2, :c=>11} # def []=( *args ) if args.length <= 2 return store( *args ) end aVals = args.pop aVals = [aVals] unless aVals.kind_of?( Array ) args.each_index{ |i| store( args[i], aVals[i] ) } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
facets-0.7.0 | lib/facet/hash/%5B%5D%3D.rb |
facets-0.7.1 | lib/facet/hash/%5B%5D%3D.rb |
facets-0.7.2 | lib/facet/hash/%5B%5D%3D.rb |