lua-users home
lua-l archive

Re: Symmetry between language and C API (Was: (not) handling new programming idioms with grace

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


On 23 July 2018 at 15:10, Scott Morgan <blumf@blueyonder.co.uk> wrote:
> On 23/07/18 15:07, Scott Morgan wrote:
>> function concat(list, sep, i, j)
>> i = i or 1
>> j = j or #list
>>
>> local tmp = {}
>> for i=1,#list do
>
> And I notice the mistake in the loop, doh!
>
> Should be `for k=i,j do` etc. etc.
it should actually work as is, just the second use of `i` shadowing
the first one on the loop's scope, without affecting the final use.
of course, lint-like tools would bark at you for this
-- 
Javier

AltStyle によって変換されたページ (->オリジナル) /