ternary op assign

Stefan Koch uplink.coder at googlemail.com
Thu May 2 18:17:12 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`

I find this syntax confusing,  I would interpret that as:

`foo[i] = (foo[i] ? bar : baz);`


More information about the dip.ideas mailing list