Ger Crowley Ger Crowley - 1 year ago 116
Ruby Question

how do you say not equal to in ruby?

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?

Is != correct?

def test
vara = 1
varb = 2
if vara == 1 && varb != 3
puts "correct"
puts "false"

Answer Source

Yes. In Ruby the not equal to operator is:


You can get a full list of ruby operators here:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download