Project

General

Profile

Feature #10505 » Update_Numeric#eql_.patch

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

View differences:

numeric.c
1049 1049
 *
1050 1050
 *  Returns +true+ if +num+ and +numeric+ are the same type and have equal
1051 1051
 *  values.
1052
 *
1053
 *     1 == 1.0          #=> true
1054
 *     1.eql?(1.0)       #=> false
1055
 *     (1.0).eql?(1.0)   #=> true
1052
 *  If the optional +block+ is given, compare between results of running +block+ for +num+ and +numeric+.
1053
 *
1054
 *     1 == 1.0                  #=> true
1055
 *     1.eql?(1.0)               #=> false
1056
 *     (1.0).eql?(1.0)           #=> true
1057
 *     4.eql?(6) { |n| n % 2 }   #=> true
1058
 *     3.eql?(-3, &:abs)         #=> true
1059
 *     1.eql?(1.0, &:itself)     #=> true
1056 1060
 */
1057 1061
static VALUE
1058 1062
num_eql(VALUE x, VALUE y)
1059 1063
{
1064
    if (rb_block_given_p()) {
1065
        return rb_equal(rb_yield(x), rb_yield(y));
1066
    }
1060 1067
    if (TYPE(x) != TYPE(y)) return Qfalse;
1061 1068
    return rb_equal(x, y);
1062
-