Sometimes I need to deal with key / value data. I dislike using Arrays, because they are not constrained in size. Furthermore, indexes of
become magic numbers of sort and do a poor job of conveying meaning. Hashes are also not appropriate, as it is possible to accidentally add an extra entry.
I wrote the following class to solve the problem:
attr_accessor :head, :tail
def initialize(h, t)
@head, @tail = h, t
It works great and solves the problem, but I am curious to know: does the Ruby standard library comes with such a class already?