Nick
08/01/2024, 9:06 PMa = { b = { c = {} } };
• a.xyz?.c
returns undefined
which makes sense per the docs because there's no a.xyz
• a.b?.xyz
also returns undefined
which is looking at existence on the right side of the ?.
operator (not in the docs)
• a.b?.c.xyz
throws an error Element c.xyz is undefined
so it seems the right side of the ?.
operator can only be undefined to 1 level
• a.b.c?.listLen()
returns undefined
which is looking at a member function's existence (not in the docs)denny
08/03/2024, 8:01 PMlistLen()
as you do: https://trycf.com/gist/bbb49912bbe17031879c89e2717d3278/lucee5?theme=monokai
The variable c
exists, so I would expect the running of listLen()
on it, which I would think should be undefined
(but in the engines I tested it was just empty, which does seem weird)
Basically, the things on the right side of the safe operator are going to be run, if the stuff on the left side existsdenny
08/03/2024, 8:04 PMwriteoutput(a.b.listLen())
which I expextNick
08/03/2024, 8:07 PMdenny
08/03/2024, 8:08 PMdenny
08/03/2024, 8:09 PMNick
08/03/2024, 8:09 PMdenny
08/03/2024, 8:12 PMNick
08/03/2024, 8:14 PMdenny
08/03/2024, 8:22 PMa.b?.xyz
(here b
exists, so it would try to evaluate what is on the right (xyz
) and throw an error)Nick
08/03/2024, 8:23 PMdenny
08/03/2024, 8:24 PMNick
08/03/2024, 8:24 PMa.b.xyz?
Nick
08/03/2024, 8:25 PMdenny
08/03/2024, 8:26 PM?
Nick
08/03/2024, 8:41 PMa.xyz?.c
does not error because a
exists and a.xyz
doesn't exist but it precedes the `?.`so it doesn't error - just returns undefined
denny
08/03/2024, 8:51 PMNick
08/03/2024, 9:26 PMMark Takata (Adobe)
08/04/2024, 3:55 PM