std.sumtype?
ryuukk_
ryuukk_ at gmail.com
Thu Mar 18 18:06:45 UTC 2021
I'm not a fan of the syntax.. why is it a library instead of a
language feature?..
```
Fahrenheit toFahrenheit(Temperature t)
{
return Fahrenheit(
t.match!(
(Fahrenheit f) => f.degrees,
(Celsius c) => c.degrees * 9.0/5 + 32,
(Kelvin k) => k.degrees * 9.0/5 - 459.4
)
);
}
```
vs
```
Fahrenheit toFahrenheit(Temperature t)
{
return match(t) {
(Fahrenheit f) => f.degrees,
(Celsius c) => c.degrees * 9.0/5 + 32,
(Kelvin k) => k.degrees * 9.0/5 - 459.4
};
}
```
I don't understand why make things confusing when it can be done
simpler
Discriminated union should be a language feature, not lib!
Because now you depend on ``std``
More information about the Digitalmars-d
mailing list