jeudi 19 juillet 2018

Erlang - If Else Condition

Trying to compute a score and maintain it between a range 0.2 to 1.5 . Will the below code work ? I don't want it to return, but continue further.

     ok = if
       Score > 1.5 ->
         Score = 1.5;
       true ->
         ok
     end,
      ok =   if
             Score < 0.2 ->
                 Score = 0.2;
             true ->
                 ok
         end,
    put(score, Score),

Aucun commentaire:

Enregistrer un commentaire