I believe this feature is specific to .NET, as it relies on runtime support by the class library. But I’ll log an issue to investigate iof we can provide support for it for the opther platforms, as well…
I am not quite familiar with JAVA, so I am not sure. Just recently want to know something about the JAVA tech stack such as Gradle, and cross platform development. But the more I study, the more I like .Net:)
But var str1 = testStr[…1]; should work on .Net since it’s C# 8 sytax.
“Unfortunately this one will have to wait until next week, probalby”, no problem, it’s not urgent for me.
Yes, this one is a compiler bug. Any “Internal Error” is.
Ok, cool.
yeah, I noticed that too. it seems any set of two or more dots gets turned into a single ellipsis character. Strange. That’s why its always good to close code snippets in back ticks (for a single line) or start./end code blocks with three backticks
var str1 = testStr[........1];
var str1 = testStr[…1];
Do you actually still see this IE? i now get a new error (logged as separate issue) with your testcase:
var str1 = testStr[..1]; // E486 Parameter 1 is "<error>", should be "Int32", in call to Char String.get Chars(Int32 index)
var str2 = testStr[1..]; // E486 Parameter 1 is "<error>", should be "Int32", in call to Char String.get Chars(Int32 index)
var str3 = testStr[^1..]; // E486 Parameter 1 is "<error>", should be "Int32", in call to Char String.get Chars(Int32 index)
var str4 = testStr[..^1]; // E486 Parameter 1 is "<error>", should be "Int32", in call to Char String.get Chars(Int32 index)
var str5 = testStr[1..6]; // E486 Parameter 1 is "Range", should be "Int32", in call to Char String.get Chars(Int32 index)
this one is being tracked as bugs://E26124: C# Range operator doesn’t work as advertised, and seems to be a combination of two slightly unrelated bugs:
(a) the .. C# language syntax just doesn’t seem to be handled correctly, for open-ended ranges
(b).NET doesn’t have explicit overlords that take a Range, but expects the compiler to map those under the hood back to normal index-based calls. this isn’t happening (properly).
…1 // From the begining but dont’t take the index 1 element, so just take the index 0 element
1… // Take the index 1 element and the rest
^1… // This one is specail. The counting is from 1. ^1 mean the last element, and because no element after it, so only output the last element.
…^1 // output all except the last element
1…6 // output the 1 to 5 elements
But what does the magic the complier did, I have no idea.