Quantcast
Channel: Active questions tagged ocaml - Stack Overflow
Viewing all articles
Browse latest Browse all 595

OCaml try with issue

$
0
0

I don't anderstand the behaviour of the try ... with ... feature of OCaml.

here is a little sample to reproduce my problem :

let () =  try int_of_string "4" with  | Failure -> -1  | n -> n

I compile with

ocamlc test.ml

Then I get this error:

File "test.ml", line 2, characters 6-23:  2 |   try int_of_string "4" with  Error: This expression has type int but an expression was expected of type unit

How can I modify my little code sample to make it work?


Viewing all articles
Browse latest Browse all 595

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>