## Feature #6555

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

=begin x <=> y returns -1, 0, 1 or nil (x <=> y) == -1 means "x less than y" and is the same as x < y (x <=> y) == 0 means "x equal y" is the same as x == y (x <=> y) == 1 means "x greater than y" and is the same as x > y (x <=> y) == nil means "x not comparable with y" and is the same as !(x <=> y) We see there is no short syntax to test if two objects are not comparable. Can we have something like (({x x >< y})), y, provided by (({Comparable})) Comparable module, that would mean "x and y are not comparable" ? As (({x x != y})) y is a short syntax for (({!(x !(x == y)})), y), can we have (({x x !< y})) y for (({!(x !(x < y)})) y) and (({x x !<= y})) y for (({!(x !(x <= y)})) y) and so on ? As (({x x <= y})) y is the same as (({(x (x < y or x == y)})), y), can we have (({x x <> y})) y for (({(x (x < y or x > y)})) y) ? Here is a list of all possible comparison operators there could be (and their meanings) : < return true when <=> return -1 ("less than") == return true when <=> return 0 ("egal") > return true when <=> return 1 ("greater than") <= return true when <=> return -1 or 0 ("equal or less than") >= return true when <=> return 1 or 0 ("equal or greater than") <> return true when <=> return 1 or -1 ("less or greater than" that is to say "comparable and different") >< return true when <=> return nil ("not comparable") !< return true when <=> return 0 or 1 or nil ("not less than", that is different from "greater than or eqal" that involves "comparable") != return true when <=> return -1 or 1 or nil ("not equal", that is different from "less or greater than" that involves "comparable") !> return true when <=> return -1 or 0 or nil ("not greater than", that is different from "less than or eqal" that involves "comparable") !<= return true when <=> return nil or 1 ("not equal nor less than", that is different from "greater than" that involves "comparable") !>= return true when <=> return nil or -1 ("not equal nor greater than", that is different from "less than" that involves "comparable") !<> return true when <=> return 0 or nil ("not less nor greater than", that is different from "egal" that involves "comparable") !>< return true when <=> return -1 or 0 or 1 ("not not comparable" or just "comparable", the same as <=> but returning a boolean) All these operators would be very useful, especially when working with partial orders (like subset-inclusion for exemple). Perhaps (({x x !== y})) y should also be a short syntax for (({!(x !(x === y)})). =end y).