Sha256: d5dbed358cfd674a46ca553b0a131137f30c16f93f1c87c3f0cd62f2d01ec9fa

Contents?: true

Size: 568 Bytes

Versions: 10

Compression:

Stored size: 568 Bytes

Contents

# TITLE:
#
#   Hash At
#
# SUMMARY:
#
#   Alias #at and #/ to #[].
#
# CREDITS:
#
#   - Thomas Sawyer

#
class Hash

  # Use division as a fetch notation.
  alias_method :/, :[]

  # For greater polymorphism with Array.
  alias_method :at, :[]

end


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

  require 'test/unit'

  class TestHashAt < Test::Unit::TestCase

    def test_at
      h = { :a=>1, :b=>2 }
      assert_equal( 1, h.at(:a) )
      assert_equal( 2, h.at(:b) )
    end
  end

=end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.0.1 lib/core/facets/hash/at.rb
facets-2.0.0 lib/core/facets/hash/at.rb
facets-2.0.2 lib/core/facets/hash/at.rb
facets-2.0.5 lib/core/facets/hash/at.rb
facets-2.1.1 lib/core/facets/hash/at.rb
facets-2.1.2 lib/core/facets/hash/at.rb
facets-2.0.4 lib/core/facets/hash/at.rb
facets-2.1.0 lib/core/facets/hash/at.rb
facets-2.0.3 lib/core/facets/hash/at.rb
facets-2.1.3 lib/core/facets/hash/at.rb