(Note: I sent a similar email last night in response to Matz, but did not see it. I apologize if this is basically a duplicate.)
Hash#== should be for would be content equals and not content and default value/proc equal. I think that most common case for == would be content equality.
Hash#=== as Nobu pointed out === would make more sense to be a membership test, i.e., alias for Hash#key?.
Hash.eql? should be content equal and default value/block (i.e what the current == is now). There is some precedence for this in Numeric where 1 == 1.0 is true but 1.eql?(1.0) is false. I see this as being very similar circumstance.
Thanks for listening,
Walt
***************************************************** Walter Szewelanczyk IS Director M.W. Sewall & CO. email : wal...@mwsewall.com 259 Front St. Phone : (207) 442-7994 x 128 Bath, ME 04530 Fax : (207) 443-6284 *****************************************************
In message "proposal Hash eql? , ==, ===" on 04/04/16, wal...@mwsewall.com <wal...@mwsewall.com> writes:
|Hash#== should be for would be content equals and not |content and default value/proc equal. I think that most common case |for == would be content equality. | |Hash#=== as Nobu pointed out === would make more sense to be a |membership test, i.e., alias for Hash#key?. | |Hash.eql? should be content equal and default value/block (i.e what |the current == is now). There is some precedence for this in Numeric |where 1 == 1.0 is true but 1.eql?(1.0) is false. I see this as being |very similar circumstance.
I agree with both Hash#== and Hash#eql? But I'm not very positive about making Hash#=== a membership test. Some usage of "===" are membership, for example, Array and Class, but they are not general consensus. I'm not sure how much useful that making === membership.