dimanche 17 février 2019

Why is the Erlang compiler saying that my clause evaluates to false?

When I try to compile the following code:

score(_X) -> mysqrt = math:sqrt(_X),
  if
    mysqrt < 100.0 -> true;
    true -> 0
  end.

The compiler says:

src/leap.erl:16: the guard for this clause evaluates to 'false'

I think I am assigning a variable mysqrt and then checking its result, which does not necessarily have to be less than 100.0. Evidently that is not what is happening. What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire