Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How does Zig represent Option<Option<i32>>? Would it be something like this?

    ??i32


I had to try it out first, but yep, that's how it works:

    const assert = @import("std").debug.assert;

    fn get12() i32 {
        const opt_opt_val: ??i32 = 12;
        const val = opt_opt_val.?.?;
        comptime assert(val == 12);
        return val;
    }
[https://www.godbolt.org/z/oncd5shvP]




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: