|
endendfor k, v in pairs(t) do f(k, v) endif not table.foreach thentable.foreach = function(t, f)
On Wed, Sep 4, 2013 at 7:36 PM, Tim Hill <drtimhill@gmail.com> wrote:It's pretty easy to add it back in with a few lines of Lua code…
On Sep 4, 2013, at 3:25 PM, Ousmane Roland Yonaba <roland.yonaba@gmail.com> wrote:
> Since Lua 5.1, table.foreach and table.foreach were deprecated[1].
> It is known (I am such a fan of Game Of Thrones... :)).
>
> I would just like to know why. Are there good reasons to this ?
> I bet there are, as looking at the evolution of Lua, nothing is seems
> to be done without some solid motives at the basis.
>
> But to me, this syntax was so much beautiful:
>
> table.foreach({...}, print)
>
> It misses me under Lua 5.2.x.
> Well, I am not saying I want it back. Just looking for...reasons.
> Thanks reading.
>
> Regards,
> Roland Y.
>
> [1] http://www.lua.org/manual/5.1/manual.html#7.2
>
-- NOT TESTED
function tableForEach(t, f)
for _, v in pairs(t) do f(v) end
end
There are endless variations of course.
--Tim