summaryrefslogtreecommitdiff
path: root/nilclass.rb
diff options
context:
space:
mode:
Diffstat (limited to 'nilclass.rb')
-rw-r--r--nilclass.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/nilclass.rb b/nilclass.rb
new file mode 100644
index 0000000000..5a2e19680d
--- /dev/null
+++ b/nilclass.rb
@@ -0,0 +1,25 @@
+class NilClass
+ #
+ # call-seq:
+ # nil.to_i -> 0
+ #
+ # Always returns zero.
+ #
+ # nil.to_i #=> 0
+ #
+ def to_i
+ return 0
+ end
+
+ #
+ # call-seq:
+ # nil.to_f -> 0.0
+ #
+ # Always returns zero.
+ #
+ # nil.to_f #=> 0.0
+ #
+ def to_f
+ return 0.0
+ end
+end