luajit2 icon indicating copy to clipboard operation
luajit2 copied to clipboard

not correct of the isarray function example

Open damonchen opened this issue 5 years ago • 2 comments

current isarray function example is

local isarray = require "table.isarray"

print(isarray{"a", true, 3.14})  -- true
print(isarray{"dog" = 3})  -- false
print(isarray{})  -- true

That is not the correct lua syntax. It should be

local isarray = require "table.isarray"

print(isarray({"a", true, 3.14}))  -- true
print(isarray({dog = 3}))  -- false
print(isarray({}))  -- true

damonchen avatar Apr 24 '20 08:04 damonchen

@damonchen thanks for your report. this change {"dog" = 3} => {dog = 3} should be good engouh since the () can be ommited. Will you help to create a PR for it? thanks :)

doujiang24 avatar May 14 '20 01:05 doujiang24

No, it's correct the way it is now. Lua doesn't require parentheses when calling functions with a table constructor as an argument.

josephcsible avatar May 14 '20 20:05 josephcsible