How will the spread operator from collection expressions mix with range objects? #7405
Captain-Quack
started this conversation in
LDM Notes
Replies: 1 comment
-
If 'range' becomes iterable then this will work. If it is not, then this will remain an error (though the error message will be better). You should get this error:
|
Beta Was this translation helpful? Give feedback.
0 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
I find it a bit worrying that both the range object and spread operator use
..
.For example, take this code:
Currently, this generates "
error CS0029: Cannot implicitly convert type 'System.Range' to 'System.Index'
". If the compier (or new programmer) sees this as a range operator, that could cause some confusion.Multidimensional collections could act strangely too:
Here,
newArray
could:0..1..3
is not valid syntax.Finally, this:
Nobody in their right mind would type this, but...
I think the spread operator is a great idea, but it could bring up a lot of questions/issues in the future.
Related:
#7351: Also raises a question of how empty/null ranges will be handled (
..
is valid syntax, and prints as0..^0
!)Beta Was this translation helpful? Give feedback.
All reactions