Difference between revisions 41294 and 41295 on zhwikivoyagelocal p = {} function p.hello( frame ) return error( message, level1 ) end -- Comment TYPE 1 --[[ Comment TYPE 2]] t = {} t["foo"] = "foo" t.bar = "bar" t[1] = "one" t[2] = "two" t[3] = "three" t[12] = "the number twelve" t["12"] = "the string twelve" t[true] = "true" t[tonumber] = "yes, even functions may be table keys" t[t] = "yes, a table may be a table key too. Even in itself." -- This returns a function that adds a number to its argument function makeAdder( n ) return function( x ) -- The variable n from the outer scope is available here to be added to x return x + n end end local add5 = makeAdder( 5 ) mw.log( add5( 6 ) ) -- prints 11 return p All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://zh.wikivoyage.org/w/index.php?diff=prev&oldid=41295.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|