A tuple is the elementary object in Rinda programming. Tuples may be matched against templates if the tuple and the template are the same size.
Creates a new Tuple from ary_or_hash
which must be an Array or Hash.
# File rinda/rinda.rb, line 51
def initialize(ary_or_hash)
if hash?(ary_or_hash)
init_with_hash(ary_or_hash)
else
init_with_ary(ary_or_hash)
end
end
Accessor method for elements of the tuple.
# File rinda/rinda.rb, line 69
def [](k)
@tuple[k]
end
Iterate through the tuple, yielding the index or key, and the value, thus ensuring arrays are iterated similarly to hashes.
# File rinda/rinda.rb, line 84
def each # FIXME
if Hash === @tuple
@tuple.each { |k, v| yield(k, v) }
else
@tuple.each_with_index { |v, k| yield(k, v) }
end
end
Fetches item k from the tuple.
# File rinda/rinda.rb, line 76
def fetch(k)
@tuple.fetch(k)
end
Commenting is here to help enhance the documentation. For example, sample code, or clarification of the documentation.
If you are posting code samples in your comments, please wrap them in "<pre><code class="ruby" > ... </code></pre>" markup in order to get syntax highlighting.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file a bug report so that it can be corrected for the next release. Thank you.