I am currently confused on what this syntax means. If i knew what it was called I would search for it but I saw it in a code and I have no idea what it means.
ptr = c < 0 ? ptr.left : ptr.right;
It is for traversing through an binary tree.
I am assuming that the first part c < 0
is a condition, and if its true, then ptr
becomes ptr.left
, and if it is false then ptr
becomes ptr.right
-
Or is it the other way around? I've never seen this before and would like some clarification. Thanks