Sha256: 83423fea01dcc90831ee810b4ee474950a9550dead6f0af2b0d7d53520891cbd
Contents?: true
Size: 556 Bytes
Versions: 5
Compression:
Stored size: 556 Bytes
Contents
class Array # Splice acts a combination of #slice! and #store. # If two arguments are given it calls #store. # If a single argument is given it calls slice!. # # a = [1,2,3] # a.splice(1) #=> 2 # a #=> [1,3] # # a = [1,2,3] # a.splice(1,4) #=> 4 # a #=>[1,4,3] # # CREDIT: Trans def splice(*args) if args.size == 1 slice!(*args) else store(*args) end end # Store a value at a givne index. # Store is an alias for #[]=. alias_method :store, :[]= end
Version data entries
5 entries across 5 versions & 1 rubygems