How to extend the string class to return this inside the square bracket?

Steven Schveighoffer schveiguy at gmail.com
Fri Aug 13 21:47:22 UTC 2021


On 8/13/21 5:05 PM, Marcone wrote:
> How to extend the string class to return this inside the square bracket 
> the same way opDollar $ returns the length of the string? Thank you.
> 
>      import std;
> 
>      void main(){
>          writeln("Hello World!"[0..this.indexOf("o")]);
>      }

There is no string class to extend.

`$` is a special token the compiler changes to `arr.length` for arrays.

-Steve


More information about the Digitalmars-d-learn mailing list