How do you check for nonempty string?

user1234 user1234 at 12.nl
Fri Apr 13 17:43:28 UTC 2018


On Friday, 13 April 2018 at 17:41:00 UTC, Adam D. Ruppe wrote:
> On Friday, 13 April 2018 at 17:38:39 UTC, Dr.No wrote:
>>>string s = null;
>>>if(s !is null && s[0] == '/')
>>
>> is this correct?
>
> No, that doesn't work if the string = "a"[$..$] for example
>
> Just use
>
> if(s.length && s[0])
>
> instead

just `if (s.length)` is enough.




More information about the Digitalmars-d-learn mailing list