From what I can tell, = and != is supposed to work on strings in OCaml. I’m seeing strange results though which I would like to understand better.
When I compare two strings with = I get the results I expect:
# "steve" = "steve";;
- : bool = true
# "steve" = "rowe";;
- : bool = false
but when I try != I do not:
# "steve" != "rowe";;
- : bool = true
# "steve" != "steve";; (* unexpected - shouldn't this be false? *)
- : bool = true
Can anyone explain? Is there a better way to do this?
!=is not the negation of=.<>is the negation of=that you should use:!=is the negation of==, and if you are an OCaml beginner, you should not be using any of these two yet. They can be a little tricky, and they are officially underspecified (the only guarantee is that if two values are==they are=).