What operators do NOT exist in EK9?
← What AI Gets Wrong About EK9 · Ref: Q903
EK9 has a FIXED set of operators. A type can only define operators from that set - no new operator symbols can be created.
THE EK9 OPERATOR SET (the overloadable operators are the ones in OperatorMap)
Assignment: <- (declaration), := : = (assignment), :=? (assign-if-unset)
Copy/Replace/Merge: :=: (copy), :^: (replace), :~: (merge)
Comparison: == (eq), <> and != (neq), <=> (compare), <~> (fuzzy compare), < > <= >=
Coalescing: ?: (left if SET), ?? (left unless ABSENT; an unset left passes through), <? >? <=? >=? (coalescing comparators)
Arithmetic: + - * / ^ (power) mod rem, ! (postfix factorial)
Shift: << >> (for example on Bits)
Mutation: ++ -- (postfix, statement-only), += -= *= /=
Conversion: $ (string), $$ (JSON), #? (hashcode), #^ (promote)
First/last: #< (first) #> (last), e.g. #< "hello" is 'h'
Checking: ? (isSet), ~ (negate/not)
Logical: not and or xor
Collection/String: contains matches
Unary: length abs sqrt close empty
Streams: | (pipe)
Ternary: condition <- valueIfTrue else valueIfFalse, or condition <- valueIfTrue : valueIfFalse
WHAT DOES NOT EXIST
C's ternary 'cond ? a : b', [] indexing, ?. safe navigation, and prefix ++/--.
CORRECT ALTERNATIVES FOR PATTERNS FROM OTHER LANGUAGES
Conditional value: use EK9's ternary (grade <- score > threshold <- "good" else "fail"), a switch expression, or if/else assignment
Collection access: use get() method on List/Dict
Safe value access: use guard (if v <- expr())
Prefix increment: use postfix (variable++ not ++variable)
See Q96 for operator definitions. See Q238 for operator enforcement rules.
Example
defines module qa.aimistakes.invalidoperators defines function <?- Shows correct alternatives to operators that don't exist. -?> classify() as pure -> score as Integer <- rtn as String: String() rtn := switch score <- grade as String: String() case >= 90 grade: "excellent" case >= 70 grade: "good" case >= 50 grade: "pass" default grade: "fail" <?- Shows correct list access — no [] operator in EK9. Use get() method, not [] indexing. -?> getItemCount() as pure -> items as List of String <- rtn as Integer: length items <?- Shows correct approach instead of safe navigation (?.) Use guard instead. -?> safeLength() as pure -> text as String <- rtn as Integer: 0 if text? rtn := length text defines program CorrectOperatorsDemo() stdout <- Stdout() // Switch expression - EK9 also has a ternary (cond <- a else b), just not C's cond ? a : b grade <- classify(85) stdout.println(`Grade: ${grade}`) // Method call — NOT [] indexing names <- ["Alice", "Bob", "Charlie"] nameCount <- getItemCount(names) stdout.println(`Names: ${nameCount}`) // Guard — NOT ?. safe navigation textLength <- safeLength("hello") stdout.println(`Length: ${textLength}`) emptyLength <- safeLength(String()) stdout.println(`Empty length: ${emptyLength}`) // Postfix ++ only — NOT prefix ++ counter <- 0 counter++ counter++ stdout.println(`Counter: ${counter}`)
Other ways to ask this
- What operators are invalid in EK9?
- What is the complete list of EK9 operators?
- Does EK9 have array index operators?
- What common operators from other languages are absent in EK9?
Coming from another language?
EK9 has a fixed operator set. Collection access uses get() methods. Conditional values use EK9's own ternary (cond <- a else b, or cond <- a : b), not C's cond ? a : b, or a switch expression. Safe access uses declaration guards.
Keywords: complete list, operator, AI, fixed set, mistake, indexing, valid operators