我正在使用以下代码来检查变量是否不为 nil 且不为零
if(discount != nil && discount != 0)
...
end
有更好的方法吗?
最佳答案
unless discount.nil? || discount == 0 # ... end
关于ruby - 在 ruby 中检查变量是否不为零且不为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/252203/