lua-users home
lua-l archive

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


This was with 5.1.4, so I'll have to go back and look it up.

On Tue, 20 Apr 2010 09:20:24 -0600, Duncan Cross <duncan.cross@gmail.com> wrote:

On Tue, Apr 20, 2010 at 2:41 PM, Stuart P. Bentley
<stuart@testtrack4.com> wrote:
One case where I've actually encountered unavoidable issues with a Lua
design due to type coercion was something like this, if I recall correctly:

num_table{[2]="This gets printed instead"}

index_searched_for="2"

print(num_table[index_searched_for] or "Even though this is what should be
printed!")

If I've got that right and am not mis-remembering the problem, then Lua 5.2
should make the change that type coercion never comes into play when
indexing tables.

It looks like you are misremembering (or maybe an older version than 5.1?):

Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
num_table = {[2]="This gets printed instead"}
index_searched_for="2"
print(num_table[index_searched_for] or "Even though this is what should be printed!")
Even though this is what should be printed!


-Duncan