The form is condition : then_value | else_value. The condition must be boolean, both branches must be type-compatible, and Nenu allows no more than two nested ternary levels. Ternary expressions have lower precedence than the ordinary logical and arithmetic operators that form their condition and results.
Arithmetic And Concatenation
Operator
Meaning
Example
+
Numeric addition, string concatenation, or compatible array concatenation.
amount + fee
-
Numeric subtraction.
paid - owed
*
Numeric multiplication.
share * people
/
Numeric division.
amount / people
%
Numeric remainder.
count % 2
Unary -
Numeric negation.
-balance
code
1number each = expense.amount / member_count2number remainder = expense.amount % member_count3string label = expense.title +" expense"4Expense[] next = expenses +[expense]
Nenu type-checks the operands. Unary minus on bool or ?, numeric arithmetic on strings, and concatenation of incompatible array element types are errors.
Comparison And Logic
Operators
Purpose
==, !=
Equality and inequality for compatible values.
>, <, >=, <=
Ordering comparisons for compatible ordered values.
and, or
Combine boolean expressions.
!
Negate a boolean expression.
??
Use the left value when present, otherwise the fallback.
Use a numeric index for an array and a string key for a map. Arrays, maps, and strings expose the equivalent numeric properties .length and .len; do not add parentheses. Arrays and maps also expose .empty. Normal indexing returns an optional value because the position or key may be missing; narrow it with with or supply a compatible fallback with ??.
1time current = time.now()2string generated = nanoid()3string short_id = nanoid(12)
Call
Return
Arguments
time.now()
time
No arguments.
nanoid()
string
No arguments; uses the default identifier length.
nanoid(length)
string
One number length argument.
Built-In Methods And Entity Methods
Built-in methods belong to the resolved receiver type. An entity does not inherit methods from its fields. A custom entity method name is rejected only when the receiver itself already has a built-in method with that name.
code
1fn filter of Expense {2return self3}
The second declaration is a small isolated example from an Item entity whose tags field is an array. It collides because arrays already provide filter. This rule is based on the receiver type, not on a global blacklist of method names.