Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
18190fa7
Commit
18190fa7
authored
Nov 21, 2015
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3030 from takahashim/nonzero
Support Numeric#zero? and Numeric#nonzero?
parents
0e721efe
40a9700e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb
mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb
+12
-0
mrbgems/mruby-numeric-ext/test/numeric.rb
mrbgems/mruby-numeric-ext/test/numeric.rb
+10
-0
No files found.
mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb
View file @
18190fa7
...
...
@@ -2,4 +2,16 @@ module Integral
def
div
(
other
)
self
.
divmod
(
other
)[
0
]
end
def
zero?
self
==
0
end
def
nonzero?
if
self
==
0
nil
else
self
end
end
end
mrbgems/mruby-numeric-ext/test/numeric.rb
View file @
18190fa7
...
...
@@ -16,3 +16,13 @@ end
assert
(
'Float#div'
)
do
assert_float
52
,
365.2425
.
div
(
7
)
end
assert
(
'Integer#zero?'
)
do
assert_equal
true
,
0
.
zero?
assert_equal
false
,
1
.
zero?
end
assert
(
'Integer#nonzero?'
)
do
assert_equal
nil
,
0
.
nonzero?
assert_equal
1000
,
1000
.
nonzero?
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment