4 ms·
...or pattern matching in case of dynamically-typed languages: case some_operation() do {:ok, result} -> # do something with result {:error, error} -
by stefanchrobot 6y ago
...or pattern matching in case of dynamically-typed languages:
case some_operation() do
{:ok, result} -> # do something with result
{:error, error} -> # handle the error
end
- leshow 6y agoYou lose the ability to make sure you've handled an error AOT, but sure, this feature is pretty much the same as a sum type except that it's structural. When I used to write typescript, there were plenty of times I was happy to have it's union types!