66

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
halfer
  • 19,824
  • 17
  • 99
  • 186
Ger Crowley
  • 901
  • 2
  • 10
  • 10

1 Answers1

133

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Rondel
  • 4,811
  • 11
  • 41
  • 67