summaryrefslogtreecommitdiff
path: root/nilclass.rb
diff options
context:
space:
mode:
authorS.H <gamelinks007@gmail.com>2021-06-03 12:04:56 +0900
committerGitHub <noreply@github.com>2021-06-02 20:04:56 -0700
commit28b481938b5c8211aad53ba82fe4ddd978ffc00f (patch)
tree5e045ebad4b85544472d543af3f25f7c01e735cf /nilclass.rb
parentbc65cf1a920b715635fbd3e658c4abdebfb87e3b (diff)
Implemented some NilClass method in Ruby code is faster [Feature #17054] (#3366)
Notes
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
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