Project

General

Profile

Feature #10505 » Update_Numeric#eql_.patch

gogotanaka (Kazuki Tanaka), 11/13/2014 12:26 AM

View differences:

numeric.c
*
* Returns +true+ if +num+ and +numeric+ are the same type and have equal
* values.
*
* 1 == 1.0 #=> true
* 1.eql?(1.0) #=> false
* (1.0).eql?(1.0) #=> true
* If the optional +block+ is given, compare between results of running +block+ for +num+ and +numeric+.
*
* 1 == 1.0 #=> true
* 1.eql?(1.0) #=> false
* (1.0).eql?(1.0) #=> true
* 4.eql?(6) { |n| n % 2 } #=> true
* 3.eql?(-3, &:abs) #=> true
* 1.eql?(1.0, &:itself) #=> true
*/
static VALUE
num_eql(VALUE x, VALUE y)
{
if (rb_block_given_p()) {
return rb_equal(rb_yield(x), rb_yield(y));
}
if (TYPE(x) != TYPE(y)) return Qfalse;
return rb_equal(x, y);
(1-1/2)