
class Array

  # Converts an array into a hash.
  #
  # This methd is just like Enumerable#to_h. But has
  # been moved in order to accomodate associtiave
  # arrays. We use to_hash becasue an Array is, 
  # in essence, a hash, just with a restricted
  # set of keys and maintained order.
  #
  #   a = [ :a, :b, :c ]
  #   a.to_hash  #=> { 0=>:a, 1=>:b, 2=>:c }
  #
  #--
  # Change to alias to_h from Enumerable?
  #++
  def to_hash
    h = {}
    each_with_index{ |e,i| h[i] = e }
    h
  end
      
end


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

  require 'test/unit'

  class TCArray < Test::Unit::TestCase

    def test_to_hash
      a = [:a,:b,:c]
      assert_equal( { 0=>:a, 1=>:b, 2=>:c }, a.to_hash )
    end

  end

=end
