LEVIATHAN v962456e · 962456eee1

Standard Library · expr

class Lit

A literal value in the expression: a string, an integer, a float, a boolean, or None.

since 0.1.0-alpha.1linuxwindowswasm

bases
Node

Overview

Enum members appear as Lit nodes holding their integer value.

Examples

expr::Lit a = expr::Lit(42);
expr::Lit c = expr::Lit(None);
match (a.v) {
    int => { console.writeln("int ${a.v}"); }
    else => { console.writeln("other"); }
}
console.writeln(c.v == None);
int 42
true

Constructors

new

new(string | int | float | bool | None value)

Create a literal node.

Parameters

value
The literal value.

Examples

expr::Lit n = expr::Lit(None);
expr::Lit t = expr::Lit(true);
console.writeln(n.v == None);
console.writeln(t.v == None);
true
false

Fields

v

string | int | float | bool | None v

The literal value. Narrow it with match before using it as a specific type.

See also

  • Node — The base class of every node in the reification tree.