7 ms·
What's really missing though is unions with destructuring `case`. Once you start coding in a language with proper unions, it's hard to go back. In python it m
by jayferd 13y ago
What's really missing though is unions with destructuring `case`. Once you start coding in a language with proper unions, it's hard to go back. In python it might look something like this:
DataType = union({ 'type1': ['field1', 'field2'], 'type2': ['field3'] })
DataType.type1(val1, val2)
DataType.type2(val3)
# pretend syntax
case datum:
DataType.type1(a, b):
doSomethingWith(a, b)
DataType.type2(c):
doSomethingWith(c)