ternary op assign

Quirin Schroll qs.il.paperinik at gmail.com
Thu May 16 16:57:17 UTC 2024


On Thursday, 2 May 2024 at 17:42:28 UTC, monkyyy wrote:
> `foo?=bar:baz` is rewritten as `foo.opOpAssign!("?:")(bar,baz)`
>
> `foo[i]?=bar:baz` opIndexOpAssign
>
> for basic types it acts as `foo=(bool)bar?foo:(typeof(foo))baz`

Isn’t this just `if (!bar) foo = baz;`?

Where would the user-defined operator be useful?


More information about the dip.ideas mailing list