Open rbuckton opened 5 years ago
C# 8 (as of Preview 5) has added a new index and slice notation ([1], [2]):
Index
^n
new Index(n, true)
Range
x..y
new Range(new Index(x), new Index(y))
..y
new Range(Index.Start, new Index(y))
x..
new Range(new Index(x), Index.End)
..
new Range(Index.Start, Index.End)
Also, since the ^ operator is currently only an infix operator, perhaps a ^ prefix operator might be worth considering for this proposal as well.
^
C# 8 (as of Preview 5) has added a new index and slice notation ([1], [2]):
Index
type (System.Index) that specifies an offset and direction.^n
syntax to specify an offset from the end of a sequence (array, etc.).^n
is shorthand fornew Index(n, true)
Range
type (System.Range) that specifies a start/endIndex
in a sequence.x..y
range operator.x..y
is shorthand fornew Range(new Index(x), new Index(y))
..y
is shorthand fornew Range(Index.Start, new Index(y))
x..
is shorthand fornew Range(new Index(x), Index.End)
..
is shorthand fornew Range(Index.Start, Index.End)
Also, since the
^
operator is currently only an infix operator, perhaps a^
prefix operator might be worth considering for this proposal as well.