From: Markus Fischer Date: 2009-05-27T18:10:10+09:00 Subject: Re: String representing relative file name, adding (meta) data? Again, for my own record: There were actually still problems with the prior approach: my test was flawed as I did not test adding two MyStr classes with the same string value. It didn't work. Thanks to the great and friendly guys over at IRC I was able to craft this solution: use a clean custom class, but implement custom hash, eql? and <=> method so it works they way I need it within the Set (which internally uses Hash) and allows sorting, too. class Resourcename attr_accessor :source_file def initialize(name, source_file = nil) @name = name.to_s @source_file = source_file end def to_s @name end def hash @name.hash end def eql? other @name.eql? other.instance_eval { @name } end def <=> other @name.<=> other.instance_eval { @name } end end The downsize is, of course, it's not a string. So whenever I need a string operation, I need to explicitly call .to_s, but I can live with that. Would be nice if it could automatically work in string context, like concatentation, too. - Markus