4 ms·
> custom guards I don't recall 100%, but I think this is a BEAM feature that exists because they don't want to run arbitrary code as part of guards that could
by davidw 3y ago
> custom guards
I don't recall 100%, but I think this is a BEAM feature that exists because they don't want to run arbitrary code as part of guards that could have side effects, delays and so on. I don't remember the specifics.
- el_oni 3y agoYou can write custom guards out of any built in function that can already be used in a guard. Like defguard is_list_or_even_int(val) do is_list(val) or (is_integer(val) and val % 2 ==0) end