lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Mon, Jul 15, 2019 at 2:07 PM Sergey Kovalev <kovserg33@gmail.com> wrote:
 
> if local fd, err = io.open("file", "r") then
>    print(fd:read("*a"))
> else
>    print("failed!", err)
> end
This is too heavy nested in case of 2 files or if you open an array of
files you have to use recursion. So this is not like it should be.


You could make an array that calls __close on its contents whenever its own __close metamethod is called. This would not require recursion.

 
--
--