[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: File-names vs file-descriptors and question on io library way of reporting errors.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 14 Jul 2011 15:54:29 -0300
> Mostly for data containers (vectors, matrices of numbers) the typical code for
> writing data to files is:
>
> local f = assert(io.open("somefile.txt", "w"))
> -- follows asserted code where I write the elements of the container to f
> f:close()
Just a detail: IIRC, you do not need to assert the 'write's. Any wrong
'write' will cause 'f:close' to fail, so you only need to assert
the 'open' and the 'close'.
-- Roberto