[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: io.read("*n") doesn't read after number parsing error
- From: Nagaev Boris <bnagaev@...>
- Date: Sat, 28 Feb 2015 19:44:24 +0000
On Sat, Feb 28, 2015 at 5:01 PM, Dirk Laurie <email@example.com> wrote:
> 2015-02-28 18:37 GMT+02:00 Nagaev Boris <firstname.lastname@example.org>:
>> if io.read("*n") returns nil (a string can't be converted into a
>> number), then all subsequent calls to io.read("*n") return nil without
>> reading the standard input.
>> $ lua5.2
>> Lua 5.2.1 Copyright (C) 1994-2012 Lua.org, PUC-Rio
>> Is it a bug?
>> Calling io.read() "repairs" io.read("*n"), i.e. the next call to
>> io.read("*n") reads the standard input.
> Since io.read("*n") is unsuccessful, the pointer in the buffer
> has not advanced. Therefore the next io.read("*n") finds the
> buffer in exactly the same state, and achieves the same
Thank you for the explanation!
Is this true, that io.read("*n") should be used if only input is
guaranteed to be a number?