32 lines
No EOL
2.2 KiB
HTML
32 lines
No EOL
2.2 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Assignment — Ludic</title>
|
||
<meta name="description" content="Store into a var, a field, or an element — a statement, not an expression.">
|
||
<link rel="stylesheet" href="base.css">
|
||
<link rel="stylesheet" href="docs.css">
|
||
</head>
|
||
<body>
|
||
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||
<main class="wrap item">
|
||
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#operators">Operators & tokens</a> <span>›</span> <span class="here">Assignment</span></div>
|
||
<div class="item-head">
|
||
<span class="kind-badge kind-operator">operator</span>
|
||
<h1 id="top">Assignment</h1>
|
||
</div>
|
||
<code class="sig">name = value</code>
|
||
<div class="desc"><p>Assignment stores a value into a target — a <code>var</code> binding, a property field, or a buffer/slice element — with <code>target = value</code>. The compound forms <code>+=</code>, <code>-=</code>, <code>*=</code>, and <code>/=</code> update in place, so <code>score += 1</code> means <code>score = score + 1</code>. Assignment is a <b>statement, not an expression</b>: it produces no value, so you cannot write <code>if x = 0</code> (use <code>==</code> for the test). Only a mutable target accepts it — assigning to a <code>let</code> or <code>const</code> binding is a compile error — though you may still mutate <b>through</b> an immutable binding that holds a record or slice.</p></div>
|
||
|
||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">var score: int = 0
|
||
score = 10
|
||
score += 5
|
||
let current_position = new_position()
|
||
current_position.column = current_position.column + 1</pre></div>
|
||
|
||
<a class="back" href="api.html">← All symbols</a>
|
||
</main>
|
||
<script src="ludic-highlight.js"></script>
|
||
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||
</body></html> |