Erlang records with both type and value restrictions as well as default values -
i trying write record represents bank account:
-record(account, { name :: atom(), type :: atom(), balance = 0 :: integer() }).
i want restrict balance >= 0
. how do this?
something balance = 0 :: 0 | pos_integer()
might trick.
edit wasn't sure existed, non_neg_integer()
better :
balance = 0 :: non_neg_integer()
Comments
Post a Comment