lua-users home
lua-l archive

Re: Assign idiom

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


Mark Edgar wrote:
> On 3/8/07, Leigh McRae <leigh.mcrae@cogeco.ca> wrote:
>> function SetIdiom(tb, v)
>> tb = v
>> return v
>> end
>> local sp = SetIdiom( self.spBackGround, W_TextRegion() )
> This will not work. tb is local to the function body; modifying it
> does not modify the actual argument.
> The following will work:
> function set(t,k,v)
> t[k] = v
> return v
> end
> local sp = set( self, "spBackGround", W_TextRegion() )
Correct. I was careful to insert the set() function into self so that it
would work. I actually tried it before I posted it, so I know it worked
as written in my message. But you definitely need three arguments (my
first one was the hidden self argument of the ':' syntactic sugar), and
you definitely need to put the name of the field in quotes.
You (Leigh) might want to consider Etan's advice, too.
Doug
-- 
Innovative Concepts, Inc. www.innocon.com 703-893-2007 x220

AltStyle によって変換されたページ (->オリジナル) /