www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - startsWith

reply Joel <joelcnz gmail.com> writes:
```d
void main() {
     import std.string : split;
     import std.algorithm.searching : startsWith;

     string bk="Exo";

     assert(("Gen Exo Lev Num Deu Jos Judg Rut 1Sam 2Sam".split~
             "1Kin 2Kin 1Chr 2Chr Ezra Neh Est Job Psa Pro Ecc Son 
Isa Jer".split~
             "Lam Eze Dan Hos Joel Amos Oba Jon Mic Nah Hab Zep 
Hag Zec".split~
	        "Mal Mat Mar Luk Joh Act Rom 1Cor 2Cor Gal Eph Phili 
Col".split~
	        "1The 2The Titu Phile Heb Jam 1Pet 2Pet 1Joh 2Joh 3Joh 
Jude Rev".split)
             .startsWith(bk));
}
```

Why doesn't this work? canFind works though.
Sep 30 2023
parent Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Sunday, 1 October 2023 at 05:33:36 UTC, Joel wrote:
 ```d
 void main() {
     import std.string : split;
     import std.algorithm.searching : startsWith;

     string bk="Exo";

     assert(("Gen Exo Lev Num Deu Jos Judg Rut 1Sam 2Sam".split~
             "1Kin 2Kin 1Chr 2Chr Ezra Neh Est Job Psa Pro Ecc 
 Son Isa Jer".split~
             "Lam Eze Dan Hos Joel Amos Oba Jon Mic Nah Hab Zep 
 Hag Zec".split~
 	        "Mal Mat Mar Luk Joh Act Rom 1Cor 2Cor Gal Eph Phili 
 Col".split~
 	        "1The 2The Titu Phile Heb Jam 1Pet 2Pet 1Joh 2Joh 3Joh 
 Jude Rev".split)
             .startsWith(bk));
 }
 ```

 Why doesn't this work? canFind works though.
Because it starts with Gen, not Exo.
Sep 30 2023