Hacker News new | past | comments | ask | show | jobs | submit login

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.



I don’t find guards “crude”, they’re actually quite elegant. At least coming from the Ruby world.


They 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.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: