Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zenroom
Zenroom
Commits
a56ad1ed
Commit
a56ad1ed
authored
May 20, 2022
by
Jaromil
Browse files
zencode array and dictionary fix the size of dicts
dictionaries were previously returning zero size
parent
f76153c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lua/zencode_array.lua
View file @
a56ad1ed
...
...
@@ -102,14 +102,25 @@ When("create the new array", function()
new_codec
(
'new array'
,
{
zentype
=
'array'
,
luatype
=
'table'
})
end
)
local
function
count_f
(
t
)
local
count
=
0
if
luatype
(
t
)
==
'table'
then
for
_
,
__
in
pairs
(
t
)
do
count
=
count
+
1
end
else
count
=
#
t
end
return
count
end
When
(
"create the length of ''"
,
function
(
arr
)
local
obj
=
have
(
arr
)
ACK
.
length
=
#
obj
ACK
.
length
=
count_f
(
obj
)
new_codec
(
'length'
,
{
luatype
=
'number'
,
zentype
=
'element'
})
end
)
When
(
"create the size of ''"
,
function
(
arr
)
local
obj
=
have
(
arr
)
ACK
.
size
=
#
obj
ACK
.
size
=
count_f
(
obj
)
new_codec
(
'size'
,
{
zentype
=
'element'
,
luatype
=
'number'
})
end
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment