What is the correct way to test for an empty string?

Rob T alanb at ucora.com
Wed Jul 17 12:18:27 PDT 2013


On Tuesday, 16 July 2013 at 19:33:13 UTC, bearophile wrote:
>
> The right, safe and readable way is to use std.array.empty:
>
> if (myString.empty)
>
> If you don't want to import functions, then test for the length:
>
> if (string.length == 0)
>
> Bye,
> bearophile

What was the rational for empty not being built in?

Is there a performance penalty using "empty"?

--rt


More information about the Digitalmars-d-learn mailing list