First Draft: opUnwrapIfTrue

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Thu Feb 26 16:00:37 UTC 2026


On 27/02/2026 4:28 AM, Juraj wrote:
> Feels like this will be hard to understand (I have to check `Result` for 
> this op), I would much rather see movement on something like this:
> <https://github.com/dlang/dmd/issues/20645>
> 
> Allowing this pattern:
> 
> ```d
> if (int value; result.tryGetValue(value)) {
>    ...
> }
> ```
> 
> IIRC, C++ has this feature as **if statements with initializer**

We talked a bit on Discord, and the point I've made is that this is a 
different feature.

Same with matching for sum types.

They will coexist with this feature, like they do in Rust and Swift.



More information about the dip.development mailing list