Sha256: 466edb5637cc99905d55936961fa7188e40981dd2f7fa2c669d63dcf1ba6e39a
Contents?: true
Size: 613 Bytes
Versions: 26
Compression:
Stored size: 613 Bytes
Contents
class Array # Fetch values from a start index thru an end index. # # [1,2,3,4,5].thru(0,2) #=> [1,2,3] # [1,2,3,4,5].thru(2,4) #=> [3,4,5] # def thru( from, to ) a = [] i = from while i <= to a << self.at(i) i += 1 end a end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCArray < Test::Unit::TestCase def test_thru assert_equal( [2,3,4], [0,1,2,3,4,5].thru(2,4) ) assert_equal( [0,1], [0,1,2,3,4,5].thru(0,1) ) end end =end
Version data entries
26 entries across 26 versions & 1 rubygems