Dictionary shorthand

New in Atfinity 17.

Description

Inside any dictionary literal, a bare identifier desugars to key: 'key'. That is, writing just the name of the key uses the same name (as a string) for the value.

This shorthand works in every dictionary literal, not only as the argument to to_dict.

You can freely mix shorthand entries with explicit key: value entries within the same dictionary.

Examples

{a, b}
// => {'a': 'a', 'b': 'b'}

Mixing shorthand and explicit values:

{a, b: 'two', c}
// => {'a': 'a', 'b': 'two', 'c': 'c'}

Last updated

Was this helpful?