Path: | lib/more/facets/tuple.rb |
Last Update: | Thu Jun 24 13:18:25 +0000 2010 |
Tuple is essentially an Array, but Comaparable and Immutable.
A tuple can be made using new or #[] just as one builds an array, or using the to_t method on a string or array. With a string tuple remembers the first non-alphanumeric character as the tuple divider.
t1 = Tuple[1,2,3] t2 = Tuple[2,3,4] t1 < t2 #=> true t1 > t2 #=> false t1 = '1.2.3'.to_t t2 = '1-2-3'.to_t puts t1 #=> 1.2.3 puts t2 #=> 1-2-3 t1 == t2 #=> true
Keep in mind that Tuple[1,2,3] is not the same as Tuple[‘1’,’2’,’3’].
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.