aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/object.c b/object.c
index c8c39a3695..a396da0913 100644
--- a/object.c
+++ b/object.c
@@ -676,17 +676,15 @@ nil_to_f(VALUE obj)
/*
* call-seq:
- * nil.to_s => ""
+ * nil.to_s => "nil"
*
- * Always returns the empty string.
- *
- * nil.to_s #=> ""
+ * Always returns the string "nil".
*/
static VALUE
nil_to_s(VALUE obj)
{
- return rb_str_new2("");
+ return rb_str_new2("nil");
}
/*
@@ -2005,6 +2003,10 @@ rb_Integer(VALUE val)
case T_STRING:
return rb_str_to_inum(val, 0, Qtrue);
+ case T_NIL:
+ rb_raise(rb_eTypeError, "can't convert nil into Integer");
+ break;
+
default:
break;
}