所以我做了一个程序做在Ruby中模师,使用一个模块:红宝石模除
module Moddiv
def Moddiv.testfor(op1, op2)
return op1 % op2
end
end
计划:
require 'mdivmod'
print("Enter the first number: ")
gets
chomp
firstnum = $_
print("Enter the second number: ")
gets
chomp
puts
secondnum = $_
puts "The remainder of 70/6 is " + Moddiv.testfor(firstnum,secondnum).to_s
当我用两个数字运行它,说70和6 ,我得到70作为输出!这是为什么发生?
sscce.org。另外,你确定这是一个关于Rails的问题吗?对我来说就像Ruby。 – 2012-03-21 16:07:28
是的,它只是红宝石,我分心,键入导轨,而不是,编辑 – Billjk 2012-03-21 16:08:34
尝试简化您的代码,并在这里发布整个事情。你可以将它简化为1行。 – 2012-03-21 16:10:24