Skip to content

IfValid

justinmann edited this page Dec 24, 2017 · 1 revision

This is special if statement that can check if an option is valid and if so allow you to access the underlying object inside the block.

a : empty'i32

b : ifValid a {
    a
} elseEmpty {
    -1
}

class(
    x : empty'i32
) { this }
c : class(valid(5))

d : ifValid bob : c?.x {
    // bob will point to the value in c.x if it has a value
}

Clone this wiki locally