Loading ...
Sorry, an error occurred while loading the content.

13968Re: "ocaml_beginners"::[] How can we rewrite pattern matching?

Expand Messages
  • Philippe Veber
    Oct 22, 2013
    • 0 Attachment
      It would help if you'd say more precisely what you want to achieve. In that very case you can use an if expression:

      if var = XType then myFun x else failwith "error"

      Note that in your original code there is a type error, as raise takes an exception as argument, not a string.


      2013/10/23 <designer16tr@...>

      What is another way to write the following code fragment:

                          match var with
                XType -> myFun x              
                          | _ -> raise("error")

    • Show all 4 messages in this topic