class Array
  # Returns the index range between two elements.
  # If no elements are given, returns the range
  # from first to last.
  #
  #   ['a','b','c','d'].range            #=> 0..3
  #   ['a','b','c','d'].range('b','d')   #=> 1..2
  #
  #--
  # This could surely use a little error catch code (todo).
  #++
  def range(a=nil,z=nil)
    if !a
      0..self.length-1
    else
      index(a)..index(z)
    end
  end
end



#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCArray < Test::Unit::TestCase

    def test_range
      a = [1,2,3,4,5]
      b = [1,2,3,4,5,6]
      assert_equal( (0..4), a.range )
      assert_equal( (0..5), b.range )
      assert_equal( (1..3), a.range(2,4) )
      assert_equal( (1..2), b.range(2,3) )
      assert_equal( (3..1), b.range(4,2) )
    end

  end

=end
