These are chat archives for evhub/coconut

23rd
Oct 2017
Iddan Aaronsohn
@iddan
Oct 23 2017 15:42
Hey! Just discovered this interesting project. What is the state of the art for working with dicts in terms of syntax and type safety in Coconut?
Evan Hubinger
@evhub
Oct 23 2017 18:53

@iddan For type safety, you'll want to use Coconut's MyPy integration. Then, for working with dicts, you can use Coconut's dictionary pattern-matching syntax:

{"a": a, "b": b, **rest} = {"a": 1, "b": 2, "c": 3}
assert a == 1 and b == 2 and rest == {"c": 3}

(here, I'm using the pattern-matching syntax in the context of destructuring assignment, though Coconut also supports the same syntax in match statements and pattern-matching function definition)