logoalt Hacker News

jzebedeeyesterday at 9:22 PM1 replyview on HN

C# is strongly-typed, not stringly-typed. The point of the union is to list possible outcomes as defined through their respective types.

The idiomatic way to do this would be to parse, don't validate [1] each string into a relevant type with a record or record struct. If you just wanted to return two results of the same type, you'd wrap them in a named tuple or a record that represented the actual meaning.

[1] https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-va...


Replies

nesarkvechnepyesterday at 9:37 PM

I guess C# is more strongly-typed than Haskell then... /s

show 2 replies