你怎么说不等于在 Ruby 中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7635867/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you say not equal to in Ruby?
提问by Ger Crowley
This is a much simpler example to what I'm trying to do in my program but is the similar idea. In an if statement how do I say say not equal to?
这是我在我的程序中尝试做的事情的一个更简单的例子,但也是类似的想法。在 if 语句中我怎么说不等于?
Is !=correct?
是!=正确的吗?
def test
vara = 1
varb = 2
if vara == 1 && varb != 3
puts "correct"
else
puts "false"
end
end
回答by Rondel
Yes. In Ruby the not equal to operator is:
是的。在 Ruby 中,不等于运算符是:
!=
!=
You can get a full list of ruby operators here: https://www.tutorialspoint.com/ruby/ruby_operators.htm.
您可以在此处获取 ruby 运算符的完整列表:https: //www.tutorialspoint.com/ruby/ruby_operators.htm。

