mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
add Integer#div and Float#div.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
module Integral
|
||||
def div(other)
|
||||
self.divmod(other)[0]
|
||||
end
|
||||
end
|
||||
@@ -13,3 +13,11 @@ assert('Integer#chr') do
|
||||
assert_raise(RangeError) { 256.chr }
|
||||
end
|
||||
end
|
||||
|
||||
assert('Integer#div') do
|
||||
assert_equal 52, 365.div(7)
|
||||
end
|
||||
|
||||
assert('Float#div') do
|
||||
assert_float 52, 365.2425.div(7)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user