29 lines
No EOL
2.3 KiB
HTML
29 lines
No EOL
2.3 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Comparison — Ludic</title>
|
||
<meta name="description" content="Compare two values and yield a bool; on strings == compares contents.">
|
||
<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">Comparison</span></div>
|
||
<div class="item-head">
|
||
<span class="kind-badge kind-operator">operator</span>
|
||
<h1 id="top">Comparison</h1>
|
||
</div>
|
||
<code class="sig">== != < <= > >=</code>
|
||
<div class="desc"><p>The comparison operators — <code>==</code> (equal), <code>!=</code> (not equal), <code><</code>, <code><=</code>, <code>></code>, <code>>=</code> — take two values and yield a <code>bool</code>, the kind of test an <code>if</code> or <code>where</code> clause wants. On <code>string</code> values <code>==</code> and <code>!=</code> compare <b>by content</b>, so <code>direction == "left"</code> checks the characters, not the pointer (a comparison against <code>null</code> stays a pointer test). Comparison binds looser than arithmetic and looser than the bitwise operators, so <code>flags & MASK == 0</code> reads as <code>(flags & MASK) == 0</code> with no parentheses needed. Chain several conditions together with <code>and</code> / <code>or</code>.</p></div>
|
||
|
||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">if current_health <= 0 { become GameOver }
|
||
if pressed_key == 'w' and elapsed_frames > 0 { row = row - 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> |