[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Safe navigation operator
- From: Cuero Bugot <cbugot@...>
- Date: Mon, 23 Aug 2010 05:23:27 -0700
> Usually the context is the table itself
> function __index(t, k)
> function __newindex(t, k, v)
> where t is the context
Well yes. What I meant by context (bad word indeed) is more something like: "this is the last access"
For instance, if you have something like "config.network.server.url" you need to know when the last access (i.e. network["url"] is done if you want to perform something specific afterwards
> Otherwise, just do
> myable.optional_value = mytable.optional_value and
> mytable.optional_value or "DEFAULT"
I was not actually mentioning default value, but rather multiple level table access. In the example above there is only one level, and it does not work if you put several levels, unless you test each level separately (which is precisely what I'd like to avoid)