What’s differenct between ‘catch 1=0’ and ‘(catch 1=0)’?
Erlang R14B03 (erts-5.8.4) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.8.4 (abort with ^G)
1> 1=0.
** exception error: no match of right hand side value 0
2> catch 1=0.
{'EXIT',{{badmatch,0},[{erl_eval,expr,3}]}}
3> (catch 1=0).
{'EXIT',{{badmatch,0},[{erl_eval,expr,3}]}}
There is no difference. The only thing that changes is when you try to bind the result of the operation to a variable:
That’s simply a question of precedence between
catchas a prefix operator, and=as an infix operator. The parentheses help make the use case unambiguous in priority.Otherwise, they’re exactly the same.