I'm practicing deletion of nodes on a binary search tree, and I created a special type for null links (NullNode) using null pattern, so I can add some desirable behaviour to "null" types. Both Node type and Nullnode type share the same INode interface, which includes recursive methods.
The INode interface includes IEnumerable recursive methods por PreOrder, InOrder and PostOrder traversal, but I don't want NullNode to return any element (through yield return statements).
What can I do?
I know that I can use an impossible if-condition and then put there a yield return statement in the method, but I don't think this solution is good. There should be a better approach.
yield
? – svick