[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Ravi-Distro 0.5 alpha release
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 16 Nov 2018 11:05:06 +0200
Op Vr. 16 Nov. 2018 om 07:26 het Egor Skriptunoff
<egor.skriptunoff@gmail.com> geskryf:
>
> On Thu, Nov 15, 2018 at 11:20 PM Dibyendu Majumdar wrote:
>>
>> Hi, to be honest the for num loop variable should be treated as
>> 'readonly' inside the loop body as it is a copy of the real index
>> variable, and changing it inside the body doesn't affect the loop, and
>> is just bad practice in my view.
>
>
> IMO, it's not a "bad practice".
> Mutability of loop variable (without affecting the loop) is quite useful.
> Examples:
>
> for name, value in str:gmatch"(%w+)=(%d+)" do
> value = tonumber(value)
> ....
> end
>
> for k = 1, 10 do
> k = tostring(k)
> ....
> end
+1.