summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authormichal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-07-02 09:58:13 +0000
committermichal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-07-02 09:58:13 +0000
commit46934759bca1d214e70ee1ed7db781202dba953a (patch)
tree6e19c7589dc0277ea8ae130c04244d845fd3a4fc /object.c
parent39e205994c917907055615146d14b3ce3054c140 (diff)
object.c: rb_Integer reformat, nil#to_f added to rb_define_method.
parse.y: Clean unused vars. range.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/object.c b/object.c
index 1f72b2a..6b6f1b5 100644
--- a/object.c
+++ b/object.c
@@ -951,8 +951,6 @@ VALUE
rb_Integer(val)
VALUE val;
{
- VALUE v;
-
switch (TYPE(val)) {
case T_FLOAT:
if (RFLOAT(val)->value <= (double)FIXNUM_MAX
@@ -961,25 +959,20 @@ rb_Integer(val)
}
return rb_dbl2big(RFLOAT(val)->value);
+ case T_FIXNUM:
case T_BIGNUM:
return val;
case T_STRING:
return rb_str_to_inum(val, 0, Qtrue);
- case T_FIXNUM:
- return val;
-
default:
break;
}
-
if (rb_respond_to(val, rb_intern("to_int"))) {
return rb_to_integer(val, "to_int");
}
- else {
- return rb_to_integer(val, "to_i");
- }
+ return rb_to_integer(val, "to_i");
}
static VALUE
@@ -1310,6 +1303,7 @@ Init_Object()
rb_cNilClass = rb_define_class("NilClass", rb_cObject);
rb_define_method(rb_cNilClass, "to_i", nil_to_i, 0);
+ rb_define_method(rb_cNilClass, "to_f", nil_to_f, 0);
rb_define_method(rb_cNilClass, "to_s", nil_to_s, 0);
rb_define_method(rb_cNilClass, "to_a", nil_to_a, 0);
rb_define_method(rb_cNilClass, "inspect", nil_inspect, 0);