Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
small code problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-07-10 (18:03)
From: Fabrice Le Fessant <fessant@p...>
Subject: Re: small code problem

 > This is a serious question (not an argumentative one).  How do I avoid 
 > Invalid_argument when I'm expecting the user to enter a filename on
 > the command-line?  Or are you just talking in general?

You can check the size of the array before reading it:

if Array.length Sys.argv < 2 then usage ();;
let filename = Sys.argv.(1)

will never raise an Invalid_argument exception.

- Fabrice