Reflection/List properties: Difference between revisions

(→‎{{header|Raku}}: Fix some internal links)
Line 426:
-- "foo = 23"
</pre>
 
=={{header|Lua}}==
<lang lua>a = 1
b = 2.0
c = "hello world"
 
function listProperties(t)
if type(t) == "table" then
for k,v in pairs(t) do
if type(v) ~= "function" then
print(string.format("%7s: %s", type(v), k))
end
end
end
end
 
print("Global properties")
listProperties(_G)
print("Package properties")
listProperties(package)</lang>
{{out}}
<pre>Global properties
number: a
table: string
number: b
table: package
table: os
table: io
table: arg
string: c
table: math
table: debug
table: table
table: coroutine
table: _G
string: _VERSION
Package properties
table: preload
table: loaded
table: loaders
string: cpath
string: config
string: path</pre>
 
=={{header|Nanoquery}}==
1,452

edits