Created
December 14, 2018 09:38
-
-
Save controlflow/8cfde44359b8f585b1b2e9062ad3c498 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public RangeKind RangeKind | |
{ | |
get | |
{ | |
var hasStartIndex = LeftOperand != null; | |
var hasEndIndex = RightOperand != null; | |
if (hasStartIndex) | |
{ | |
return hasEndIndex ? RangeKind.FromStartToEnd : RangeKind.FromStart; | |
} | |
// else | |
{ | |
return hasEndIndex ? RangeKind.ToEnd : RangeKind.Full; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public RangeKind RangeKind | |
{ | |
get | |
{ | |
switch (LeftOperand, RightOperand) | |
{ | |
case ({ }, { }): return RangeKind.FromStartToEnd; | |
case ({ }, null): return RangeKind.FromStart; | |
case (null, { }): return RangeKind.ToEnd; | |
case (null, null): return RangeKind.Full; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public RangeKind RangeKind | |
{ | |
get | |
{ | |
return (LeftOperand, RightOperand) switch | |
{ | |
({ }, { }) => RangeKind.FromStartToEnd, | |
({ }, null) => RangeKind.FromStart, | |
(null, { }) => RangeKind.ToEnd, | |
(null, null) => RangeKind.Full | |
}; | |
} | |
} |
@aensidhe That one is not supported :)
switch (LeftOperand, RightOperand)
is a statement, while expression body requires expression. Also semicolon at the end is missing :D
The correct option will be like this:
public RangeKind RangeKind => (LeftOperand, RightOperand) switch
{
({ }, { }) => RangeKind.FromStartToEnd,
({ }, null) => RangeKind.FromStart,
(null, { }) => RangeKind.ToEnd,
(null, null) => RangeKind.Full
};
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.