Association

General binary association allows one object to be associated with another. It has a variety of uses, link-lists, simple ordered maps and mixed collections, among them.

Usage

Associations can be used to draw simple relationships.

  :Apple >> :Fruit
  :Apple >> :Red

  :Apple.associations #=> [ :Fruit, :Red ]

It can also be used for simple lists of ordered pairs.

  c = [ :a >> 1, :b >> 2 ]
  c.each { |k,v| puts "#{k} associated with #{v} }

produces

  a associated with 1
  b associated with 2

Limitations

The method :>> is used to construct the association. It is a rarely used method so it is generally available. But you can‘t use an Association while extending any of the following classes becuase they use #>> for other things.

  Bignum
  Fixnum
  Date
  IPAddr
  Process::Status

Author

  • Thomas Sawyer

License

  Copyright (c) 2005 Thomas Sawyer

  Ruby License

  This module is free software. You may use, modify, and/or redistribute this
  software under the same terms as Ruby.

  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.