=:= vs == and a shorter version of if

Raimo Niskanen raimo@REDACTED
Mon Apr 18 14:51:26 CEST 2005


joelr1@REDACTED (joel reymont) writes:

> Howdy!
> 
> Should I always use =:= instead of == if I don´t need type conversion?
> How much more efficient is that?

Hardly noticable. It will cost you one more character to type :-)
Ordinary matching uses =:= so it is the one you really often want
to use, but == only differs for float vs integer so it is mostly 
the same.

> 
> Also, is there a shorter way of saying the following? 
> 
> if
>     SomeCondition -> 
>         dostuff;
>    true -> 
>         ok
> end.
> 
>     Thanks, Joel
> 

if SomeCondition -> dostuff;
    true -> ok end.

%% Sorry about that, could not resist... this might be better:

SomeCondition andalso dostuff.  % Warning! not tail recursive.

> -- 
> http://wagerlabs.com/tech

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list