How to display aliases for specific methods
When I asked you a question, I found that group_by
's equivalence decision was not ==
or eql?
but I couldn't find the document when I looked for what was being used.
I searched ruby source code by def group_by
, but found only test code...
Under what conditions does group_by
determine that they are identical?
If group_by
is used to assemble a hash, it would be hash
.
This is what happened when I tried it.
irb(main): 043:0>a=Object.instance_method(:debugger)
=>#<UnboundMethod:Object(Kernel)#debugger(byebug)>
irb(main): 044:0>b=Object.instance_method(:byebug)
=>#<UnboundMethod:Object(Kernel)#byebug>
irb(main): 045:0>a==b
=>true
irb(main): 046:0>a.eql?(b)
=>true
irb(main): 047:0>a.hash==b.hash
=>false
irb(main): 048:0>Hash.instance_method(:has_key?).hash==Hash.instance_method(:member?).hash
=>true
The Object#hash documentation contains
If A.eql?(B), then A.hash==B.hash
You must meet the relationship.
It says, but the above behavior doesn't seem to be the same
© 2024 OneMinuteCode. All rights reserved.