Kind of a basic question, but I don't have the vocabulary to put together a proper Google search to answer my question.
Basically, there seems to be two different ways of referring to a key or item within an array or JSON object. One way is like this:
item()['key']
The other is the same, but has a question mark:
item()?['key']
(of course "item()" could be replaced with anything that is an object or an array)
I've seen both methods used in different tutorials, and in most cases in my personal use, it seems like there are some instances when either method works. BUT I have run into situations where one method works, but not the other.
So what's the difference? How do I know whether or not to include the question mark?
Thanks,
Hello @Jronash
The ? Is there for handling instances where the value cannot be found. The ? Returns a null value rather than throwing an error.
This post has a great example:
Michael E. Gernaey
497
Super User 2025 Season 2
David_MA
436
Super User 2025 Season 2
Riyaz_riz11
244
Super User 2025 Season 2