On Friday, 13 August 2021 at 21:47:22 UTC, Steven Schveighoffer wrote:
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

Isn't there some unario operator template that I can use with lambda to handle a string literal?

Reply via email to