rsc3/doc-schelp/HelpSource/Classes/Association.schelp

71 lines
1.1 KiB
Text

CLASS::Association
summary::relate two objects
categories::Collections
DESCRIPTION::
Associates a key with a value.
Associations can be created via the -> operator which is defined in class link::Classes/Object::.
Associations are used internally in link::Classes/Dictionary::.
CLASSMETHODS::
method::new
Create an Association between two objects.
code::
(
x = 'name' -> 100;
x.postln;
)
::
argument::key
any object
argument::value
any object
INSTANCEMETHODS::
subsection::Accessing
method::key
the key object.
method::value
the value object.
subsection::Testing
method::==
Compare the keys of two Associations.
method::<
Compare the keys of two Associations.
method::hash
Compute the hash value of the Association.
subsection::Writing to streams
method::printOn
Write a string representation to the stream.
method::storeOn
Write a compilable string representation to the stream.
EXAMPLES::
code::
// associations can be a good way to store named data in order:
(
a = [\x -> 700, \y -> 200, \z -> 900];
fork {
a.do { |assoc|
assoc.key.postln;
assoc.value.postln;
(freq: assoc.value).play;
2.wait;
}
};
)
::