lua-users home
lua-l archive

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


On Tue, 20 Apr 2010 10:50:26 -0400
Henk Boom <henk@henk.ca> wrote:

> On 20 April 2010 09:41, 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.
> 
> Doesn't seem to be an issue to me:
> 
> > 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!
> 
>     henk

Indeed!

Denis
________________________________

vit esse estrany ☣

spir.wikidot.com