Sha256: 3b0d7391b1628435b02b5669c7c55ea802f099ab38939a5c91a11db139a7d1e0
Contents?: true
Size: 497 Bytes
Versions: 2
Compression:
Stored size: 497 Bytes
Contents
class Array # Divide on matching pattern. # # ['a1','b1','a2','b2'].divide(/^a/) # #=> [['a1','b1'],['a2','b2']] # # ['a1','b1','a2','b2'].divide(/^b/) # #=> [['a1',['b1','a2'],[]'b2']] # # ['a1','b1','a2','b2'].divide(/^c/) # #=> [['a1','b1','a2','b2']] # # CREDIT: Trans def divide(pattern) memo = [] memo.push [] unless pattern === first each do |obj| memo.push [] if pattern === obj memo.last << obj end memo end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
facets-glimmer-3.2.0 | lib/core/facets/array/divide.rb |
facets-3.1.0 | lib/core/facets/array/divide.rb |