C#C
C#3y ago
morry329#

✅ Operator ?? functions

I came across ?? operators whilst I try to understand solutions like https://leetcode.com/problems/n-ary-tree-preorder-traversal/solutions/3065645/not-fast-but-good-solution-without-any-recursion/

For example there is this line of code
root.children[0].children = new List<Node>(root.children[0].children ?? new List<Node>()) {root.children[i]};
`

In this case the ?? operator is ordering the IDE like "hey, the value root.children[0].children can be the value of root.children at the ith position ?
LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
Was this page helpful?