In ocaml, I want to have many nested if statements and a return value on each of the conditions. The code is becoming complicated like this.
let func arg1 arg2 =
if condition1 then arg1+arg2
else
(
//code1
if condition2 then arg1*arg2
else
(
//code2
if condition3 then arg1+arg2
else
(
//code3
)
)
)
Instead of such nested statements can I have code like this?
let func arg1 arg2 =
if condition1 then arg1+arg2
//code1
if condition2 then arg1*arg2
//code2
if condition3 then arg1+arg2
//code3
Aucun commentaire:
Enregistrer un commentaire