Sha256: 4e658af91855bf8ca5b93d17ccc0d694db5b53457af166cdde57b12fa0469df7
Contents?: true
Size: 502 Bytes
Versions: 26
Compression:
Stored size: 502 Bytes
Contents
class Array # Returns the last index of the array. # Returns nil is array has no elements. # # [1,2,3,4,5].last_index #=> 4 # def last_index return nil if self.length == 0 self.length - 1 end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCArray < Test::Unit::TestCase def test_last_index assert_equal( [1,2,3,4,5].last_index, 4 ) end end =end
Version data entries
26 entries across 26 versions & 1 rubygems