It a bit unclear whether you want to make one array with {1,2,3,4} or two-dim array like {{1;2};{3;4}}.
i.e.
:local notificationTeam {{"mateo";"mateo@example.com"};{"carlo";"carlo@example.com"}}
vs.
:local notificationTeam {{"sofia@example.com";"mateo@example.com"},{"beatrice@example.com";"carlo@example.com"}}
Note: the semi-colon ; appends to ITEM to a array (and the item could be an array). Or, the comma, join TWO LIST together into one (i.e. makes it one-dimensional). So comma and semi-colon will give radically different results.
It's sometimes hard to see what happens with arrays and the ":put" – they sometime will look the same, when printed, but be internally different... i.e.
It is confusing.
So viewing the array as JSON often makes the differences more apparent when testing things out:
i.e.
:local notificationTeam {{"mateo";"mateo@example.com"};{"carlo";"carlo@example.com"}}
vs.
:local notificationTeam {{"sofia@example.com";"mateo@example.com"},{"beatrice@example.com";"carlo@example.com"}}
Note: the semi-colon ; appends to ITEM to a array (and the item could be an array). Or, the comma, join TWO LIST together into one (i.e. makes it one-dimensional). So comma and semi-colon will give radically different results.
It's sometimes hard to see what happens with arrays and the ":put" – they sometime will look the same, when printed, but be internally different... i.e.
Code:
{ :local semi {{"mateo";"mateo@example.com"};{"sofia";"sofia@example.com"}}:put $semi# mateo;mateo@example.com;sofia;sofia@example.com:local comma ({"mateo";"mateo@example.com"},{"sofia";"sofia@example.com"}):put $comma# mateo;mateo@example.com;sofia;sofia@example.com# they look the same, but not same when accessing...:put ($semi->1->1)# sofia@example.com:put ($comma->1->1)# (gets nothing)# and only the comma version has a 3rd element...:put ($semi->3)# (gets nothing):put ($comma->3)# sofia@example.com# BOTH out put of :put look IDENTICAL}
It is confusing.
So viewing the array as JSON often makes the differences more apparent when testing things out:
Code:
# if it was {name; email};...:put [:serialize to=json {{"mateo";"mateo@example.com"};{"sofia";"sofia@example.com"}}]# [["mateo","mateo@example.com"],["sofia","sofia@example.com"]]# but the the comma, now a list....within a list:put [:serialize to=json {{"mateo";"mateo@example.com"},{"sofia";"sofia@example.com"}}]# [["mateo","mateo@example.com","sofia","sofia@example.com"]]# so you do need parentheses if you want a one-dim array, without the extra outlist:put [:serialize to=json ({"mateo";"mateo@example.com"},{"sofia";"sofia@example.com"})]# ["mateo","mateo@example.com","sofia","sofia@example.com"]# and you cannot even do this one.:put [:serialize to=json ({"mateo";"mateo@example.com"};{"sofia";"sofia@example.com"})]# syntax error (line 1 column 56)# but it was just two list of emails, always semi-consoles:put [:serialize to=json ({"igor@example.lv";"mateo@example.com"},{"nadia@example.lv";"sofia@example.com"})]# ["igor@example.lv","mateo@example.com","nadia@example.lv","sofia@example.com"]# or:put [:serialize to=json (("igor@example.lv","mateo@example.com"),("nadia@example.lv","sofia@example.com"))]# ["igor@example.lv","mateo@example.com","nadia@example.lv","sofia@example.com"]# just not...:put [:serialize to=json (("igor@example.lv","mateo@example.com");("nadia@example.lv","sofia@example.com"))]# syntax error (line 1 column 45)
Statistics: Posted by Amm0 — Sat Jun 01, 2024 1:10 am