本页尚未翻译,以下为英文原文。
#E0019: operators that need parentheses
A chain of comparisons takes its operators from one group: < and <= (0 <= i < n), > and >= (a > b >= c), or == (a == b == c); each pair is joined with &&. Other chains are an error: mixed groups (a < b > c, a < b == c), a != b != c, x ∈ s == y and a..b..c. Join the parts with && (a < b && b > c), or add parentheses to say which you mean. (An index with several parts on a one-axis type, xs[1:, 0], is E0143.)
nabi
let a = 1;
let b = 2;
println(f"{a < b > 0}");
error[E0019]: `<` and `>` cannot be chained --> main.nabi:3:18 | 3 | println(f"{a < b > 0}"); | ^ | = help: a chain compares in one direction (`a < b <= c`, `a > b >= c`, `a == b == c`); write `a < b && b > c`
Join the two comparisons with &&; a chain in one direction is fine:
nabi
let a = 1;
let b = 2;
println(f"{a < b && b > 0} {0 <= a < b}");
true true
Related: E0010 unexpected token
Found a mistake? Edit this page on GitHub. Last updated