On Friday, 13 August 2021 at 21:05:22 UTC, 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")]); }
this does not exist (and see few reason for) but algo + ufcs allows this easily, e.g
``` "Hello World!".findSplit("o")[0].writeln; ``` bonus: both can throw bound error