digitalmars.D.learn - startsWith
- Joel (18/18) Sep 30 2023 ```d
- Imperatorn (2/20) Sep 30 2023 Because it starts with Gen, not Exo.
```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
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