From: rpmohn@... (Ross Mohn) Date: 2000-11-30T03:40:02+09:00 Subject: [ruby-talk:6645] Re: Hash with a key of nil ? Dave@thomases.com (Dave Thomas) wrote in : >rpmohn@panix.com (Ross Mohn) writes: >> >> 1) Should nil be allowed as a Hash key? This does not make sense to >> me. 2) Maybe there should be a method defined for nil.<=> ? I think if >> it always returned -1 it would be appropriate. > >Perhaps the alternative questions might be: should you always be able >to sort a hash based on it's keys? I suspect the answer is "no". For >example: > > h = { STDIN => 1, STDOUT => 2 } > > STDIN <=> STDOUT > NameError: undefined method `<=>' for # > > >Hash keys need only provide #hash and #eql?. There's no requirement for ><=>, so in general you can't rely on being able to sort a hash. I guess so, but I don't know if I'm convinced yet. Maybe it's just that I'm not used to such a flexible language? Thanks for re-stating the question more correctly -RPM -- Ross Mohn rpmohn@panix.com