aboutsummaryrefslogtreecommitdiffhomepage
path: root/notes/if_as.txt
blob: ea75bc3047114050857a2713e3770e8de36526ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

"if as" syntax
==============

Useful for optional types:

    if find_user("admin") as ref User u {
        # User found (return value is not none)
        ...
    } else {
        # User not found (return value is none)
        ...
    }

This could be extended to support integer overflow handling also:

    if  might_overflow(a + b) as int i {
        ...
    }

Or even have + do overflow checking if the target type is ?int.

    ?int c = a + b

    if a + b as int i {
        ...
    }