Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-12

String comparison

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Damien Gerard

Just another question :)
What is the most efficient way to check if a string is empty or not ?

if s = '' then ...
of this one
if Length(s) 0 then ...

Damien Gerard People who used magic without knowing what they were doing usually came to a sticky end. All over the entire room, sometimes. -- (Terry Pratchett, Moving Pictures)
Daniël Mantione
to Damien Gerard

Op Fri, 21 Dec 2007, schreef Damien Gerard:

Show quoted text 7 lines
Just another question :) What is the most efficient way to check if a string is empty or not ? if s = '' then ... of this one if Length(s) 0 then ...

Both generate the same code.

Daniël

Damien Gerard
to Daniël Mantione
Daniël Mantione wrote 13 lines
Op Fri, 21 Dec 2007, schreef Damien Gerard: > > Just another question :) > What is the most efficient way to check if a string is empty or not ? > > if s = '' then ... > of this one > if Length(s) 0 then ... Both generate the same code.

Thanks !

Damien Gerard People who used magic without knowing what they were doing usually came to a sticky end. All over the entire room, sometimes. -- (Terry Pratchett, Moving Pictures)