
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
