Refactoring ternary expressions into null-coalescing operations and vice versa
May 25th, 2011
Comments off
There are two interesting refactorings shipped in Refactor! Pro:
- Compress to Null Coalescing Operation
- Expand Null Coalescing Operation
The first one converts a ternary expression into an equivalent null coalescing operation. The second one is the opposite of the first one – it converts a null coalescing operation to an equivalent ternary expression. Both refactorings are available in CSharp only, because Visual Basic, for example, doesn’t have a null coalescing operator.