34 lines
No EOL
2.1 KiB
HTML
34 lines
No EOL
2.1 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>List.push — Ludic</title>
|
||
<meta name="description" content="Append an element to the end of a slice.">
|
||
<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="ns-list.html">List</a> <span>›</span> <span class="here">List.push</span></div>
|
||
<div class="item-head">
|
||
<span class="kind-badge kind-method">method</span>
|
||
<h1 id="top">List.push</h1>
|
||
</div>
|
||
<code class="sig">List.push(s, v) -> void</code>
|
||
<div class="desc"><p>Adds <code>v</code> to the end of <code>s</code>, growing the backing buffer if needed, so the slice's length increases by one. It is the same operation as the bare <code>push(s, v)</code>. Because a slice is shared, the new element is visible to every holder. Use it to collect spawned entities, build a list of hits, or fill an inventory.</p></div>
|
||
<div class="params"><h2>Parameters</h2><div class="param" id="param-s"><code class="pname">s</code><span class="pdesc">the slice to append to</span></div><div class="param" id="param-v"><code class="pname">v</code><span class="pdesc">the element to add (matching the slice's element type)</span></div></div>
|
||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Collect {
|
||
var picked: []int = new []int
|
||
|
||
handler Grab phase Update {
|
||
List.push(picked, 7)
|
||
}
|
||
}</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> |