This is a much simpler example of what I'm trying to do in my program but is a similar idea. In an, if statement how do I say not equal to?
Is !=
correct?
def test vara = 1 varb = 2 if vara == 1 && varb != 3 puts "correct" else puts "false" end end
Ruby has an or-equals operator that allows a value to be assigned to a variable if and only if that variable evaluates to either nil or false .
The not-equal-to operator ( != ) returns true if the operands don't have the same value; otherwise, it returns false .
It lets you add items to a collection or even concatenate strings.
Yes. In Ruby the not equal to operator is:
!=
You can get a full list of ruby operators here: https://www.tutorialspoint.com/ruby/ruby_operators.htm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With