Sha256: 790cfef706903e7172f0d59c72b2c81258ce290ed9c2bc35e036fea13151d7f6
Contents?: true
Size: 817 Bytes
Versions: 109
Compression:
Stored size: 817 Bytes
Contents
# encoding: utf-8 require 'open_classes/array/together_helper' # Array class Array include TogetherHelper # Arrays bulk slice. # # together_slice has alias :tslice # # === Examples # # single args case # # lists = [[*1..5], [*6..10]] # ret = lists.together_slice 2 # print ret # => [3, 8] # # multi args case # # lists = [[*1..5], [*6..10]] # ret = lists.together_slice 2, 2 # print ret # => [[3, 4], [8, 9]] # # range args case # # lists = [[*1..5], [*6..10]] # ret = lists.together_slice (2..3) # print ret # => [[3, 4], [8, 9]] # def together_slice(*args) if_not_contain_array_rails_type_error reduce([]) { |ret, list|ret << list.slice(*args) } end alias_method :tslice, :together_slice end
Version data entries
109 entries across 109 versions & 1 rubygems