Stream: beginners

Topic: ✔ syntax on record destructuring alias


view this post on Zulip Steven Chen (Dec 10 2024 at 17:25):

The current syntax is original_name: new_name tripping me every time. How should I overcome this :joy:

e.g.

addAndStringify = \{ birds, iguanas: lizards } ->
    Num.toStr (birds + lizards)

But in my mind, I feel new_name: original_name is more natural. In record syntax likex: y, x is the identifier, y is the value. In the example above, in the scope of addAndStringify, lizards feels like the new identifier and iguanas should be the value.

view this post on Zulip Richard Feldman (Dec 10 2024 at 17:28):

what if it were { original_name as new_name } ?

view this post on Zulip Steven Chen (Dec 10 2024 at 17:29):

yeah. A different operator or keyword would fix it :)

view this post on Zulip Richard Feldman (Dec 10 2024 at 17:29):

that's something I've been thinking about from a consistency perspective, because as is how we rename things pretty much everywhere else

view this post on Zulip Brendan Hansknecht (Dec 10 2024 at 17:30):

goodbye symmetry....but makes sense

view this post on Zulip Notification Bot (Dec 10 2024 at 22:39):

Steven Chen has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC