lua-users home
lua-l archive

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


On Tue, Jan 30, 2018 at 6:04 PM, Sean Conner <sean@conman.org> wrote:

  The conversion of var, limit and step to numbers is preventing the use of
custom types that cannot be converted to numbers:

        for i = "1" , "10" , "2" do print(i) end


BTW, about the conversion:

Lua 5.4.0  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> "2"+3
5
> "2"+"3"
5

 
The result is an integer!  And I like it!
 
> for j = "1", 2, 3 do print(j, math.type(j)) end
1.0     float
> for j = 1, "2", 3 do print(j, math.type(j)) end
1       integer
> for j = 1, 2, "3" do print(j, math.type(j)) end
1.0     float
 
Why does the loop variable hold not an integer sometimes?