aboutsummaryrefslogtreecommitdiff
path: root/docs/language_manual/tipsandtricks.md
blob: c2f2bda9beeebe5ed8adfa43656b1296d1995b39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

Tips and Tricks
===============

Default values for structs
--------------------------
LRL does not (and will not) have default values for structs built in, but
you can do something similar by combining multiple assignment and a typescope:

    typedef Person = (
        byte#[undefined]+> name,  // FIXME assigning to this array does not work due to it having an unknown length
        int age,
    );
    Person Person:defval = (@"John Doe", 40);

Then you can use it:

    var Person jane = :defval;
    jane.name = @"Jane Doe";

    // The result is (@"Jane Doe", 40);