3 ms·
Elixir has features called guards which allow you to check for a condition to be true before a function is called(and will match another version of the same fun
by tryptophan 3y ago
Elixir has features called guards which allow you to check for a condition to be true before a function is called(and will match another version of the same function if it is false). This is used as a crude form of type checking.
- cpursley 3y agoI don’t find guards “crude”, they’re actually quite elegant. At least coming from the Ruby world.
- sodapopcan 3y agoThey were saying guards are a crude form of type-checking, not intrinsically crude. Really they are a perfectly regular form of type hinting--as is pattern matching in function heads--when being used for no other purpose than to ensure the correct type is passed at runtime.