Programs live in .kj files. Edit any example and press Run to compile it
and see its output. Each example runs independently.
Values
Write a type after :. () is the value of Unit; List[Number] holds
numbers. Semicolons end statements, and // starts a comment.
Show a QR code for your glasses, or send a link to another browser. You can keep working here.
Sharing starts a fresh run of the last compiled code. Your editor draft stays here.
Join a session
Open an invitation link, or paste a link or code from the other device.
On RayNeo, open Menu → Connect live and scan this code. In another browser, open the invitation link below.
Or enter this code:
Waiting for another device. You can keep working while it connects.
Browsers can edit code; every device can use scene controls. The device that started the session controls playback.
Connection settings
A full invitation link includes its host. With a code alone, both devices need the same live host. Pairing setup
No output.
- Executed source spans appear here.
Try changing 7 to 2.5. Number supports fractions as well as whole numbers.
Replace it with "seven" to see a type error.
See Number for the compatibility alias,
Numbers, text and bytes for exact widths, and
Tensors and media for shaped arrays.
Bindings
let fixes a binding; let mut lets you assign another value of the same type.
A local binding can infer its type from the first value.
Show a QR code for your glasses, or send a link to another browser. You can keep working here.
Sharing starts a fresh run of the last compiled code. Your editor draft stays here.
Join a session
Open an invitation link, or paste a link or code from the other device.
On RayNeo, open Menu → Connect live and scan this code. In another browser, open the invitation link below.
Or enter this code:
Waiting for another device. You can keep working while it connects.
Browsers can edit code; every device can use scene controls. The device that started the session controls playback.
Connection settings
A full invitation link includes its host. With a code alone, both devices need the same live host. Pairing setup
No output.
- Executed source spans appear here.
Try changing count = 3 to count = count + 5: the first output becomes 6.
Assigning true instead fails compilation; mutability does not change the type.
Operators
Use arithmetic to calculate, comparisons to produce a Bool, and and, or,
or ! to combine or negate conditions. Parentheses control grouping.
Show a QR code for your glasses, or send a link to another browser. You can keep working here.
Sharing starts a fresh run of the last compiled code. Your editor draft stays here.
Join a session
Open an invitation link, or paste a link or code from the other device.
On RayNeo, open Menu → Connect live and scan this code. In another browser, open the invitation link below.
Or enter this code:
Waiting for another device. You can keep working while it connects.
Browsers can edit code; every device can use scene controls. The device that started the session controls playback.
Connection settings
A full invitation link includes its host. With a code alone, both devices need the same live host. Pairing setup
No output.
- Executed source spans appear here.
Try removing the parentheses: 2 + 3 * 4 produces 14 instead of 20.
Try true and false, then true or false: compare false and true.
Both operators short-circuit: false and expression and true or expression
skip the expression on the right. and binds more tightly than or.
Functions
func names a function. Parameters and the return type are explicit;
ret value; returns a result, while ret; exits a Unit function.
Show a QR code for your glasses, or send a link to another browser. You can keep working here.
Sharing starts a fresh run of the last compiled code. Your editor draft stays here.
Join a session
Open an invitation link, or paste a link or code from the other device.
On RayNeo, open Menu → Connect live and scan this code. In another browser, open the invitation link below.
Or enter this code:
Waiting for another device. You can keep working while it connects.
Browsers can edit code; every device can use scene controls. The device that started the session controls playback.
Connection settings
A full invitation link includes its host. With a code alone, both devices need the same live host. Pairing setup
No output.
- Executed source spans appear here.
Try double(5) to get 10. double(true) is a compile error because x
requires a Number.
Conditions
if chooses a branch using a Bool. else handles the other case.
Show a QR code for your glasses, or send a link to another browser. You can keep working here.
Sharing starts a fresh run of the last compiled code. Your editor draft stays here.
Join a session
Open an invitation link, or paste a link or code from the other device.
On RayNeo, open Menu → Connect live and scan this code. In another browser, open the invitation link below.
Or enter this code:
Waiting for another device. You can keep working while it connects.
Browsers can edit code; every device can use scene controls. The device that started the session controls playback.
Connection settings
A full invitation link includes its host. With a code alone, both devices need the same live host. Pairing setup
No output.
- Executed source spans appear here.
Try a score of 3: the output changes from pass to try again.
if score { ... } would be invalid; numbers are not Boolean conditions.
Loops
For each value
for value in collection visits a list in order. continue skips to the next
iteration; break exits the loop. This example prints 1 and 3.
Show a QR code for your glasses, or send a link to another browser. You can keep working here.
Sharing starts a fresh run of the last compiled code. Your editor draft stays here.
Join a session
Open an invitation link, or paste a link or code from the other device.
On RayNeo, open Menu → Connect live and scan this code. In another browser, open the invitation link below.
Or enter this code:
Waiting for another device. You can keep working while it connects.
Browsers can edit code; every device can use scene controls. The device that started the session controls playback.
Connection settings
A full invitation link includes its host. With a code alone, both devices need the same live host. Pairing setup
No output.
- Executed source spans appear here.
Try changing value == 2 to value == 3: the output becomes 1 and 2.
While a condition holds
while checks its condition before each iteration. This countdown prints
3, 2, 1, then done.
Show a QR code for your glasses, or send a link to another browser. You can keep working here.
Sharing starts a fresh run of the last compiled code. Your editor draft stays here.
Join a session
Open an invitation link, or paste a link or code from the other device.
On RayNeo, open Menu → Connect live and scan this code. In another browser, open the invitation link below.
Or enter this code:
Waiting for another device. You can keep working while it connects.
Browsers can edit code; every device can use scene controls. The device that started the session controls playback.
Connection settings
A full invitation link includes its host. With a code alone, both devices need the same live host. Pairing setup
No output.
- Executed source spans appear here.
Try starting at 0: only done prints. Without the subtraction the loop cannot
finish; the runtime stops it when its execution budget runs out.
Lists
Index from zero with values[0]. append returns a new list, and len counts
its entries. An empty list needs an element type.
Show a QR code for your glasses, or send a link to another browser. You can keep working here.
Sharing starts a fresh run of the last compiled code. Your editor draft stays here.
Join a session
Open an invitation link, or paste a link or code from the other device.
On RayNeo, open Menu → Connect live and scan this code. In another browser, open the invitation link below.
Or enter this code:
Waiting for another device. You can keep working while it connects.
Browsers can edit code; every device can use scene controls. The device that started the session controls playback.
Connection settings
A full invitation link includes its host. With a code alone, both devices need the same live host. Pairing setup
No output.
- Executed source spans appear here.
Try values[1] to print 4. values[2] fails at runtime: appending created
added, leaving the two entries in values unchanged.
Continue with Types and traits to give values fields and methods. Exact syntax and type rules live in the language reference; available helpers are in the standard library.