Question about the $ sign in arrays and strings

mipri mipri at minimaltype.com
Wed Feb 19 07:06:20 UTC 2020


On Wednesday, 19 February 2020 at 07:04:48 UTC, Namal wrote:
> Hello, I wanted to remove the lastchar in a string and figured 
> that you can do that wit
>
> str = str[0..$-2];
>
> but why is
>
> str = str[0..$] and str=str[0..$-1]
>
> the same ?

Why do you think that they are the same?

$ rdmd --eval 'auto str = "hello"; writeln(str = str[0..$]); 
writeln(str = str[0..$-1])'
hello
hell



More information about the Digitalmars-d-learn mailing list