What is the best approach, simple string concatenation or string.format
?
For instance, what is the better to use:
s:=v1+\' \'+v2
Depends on your criteria for "best". If all you're doing is concatenating two strings, I'd go with the + operator. It's obvious what you're trying to do and easy to read, and it's a little bit faster because it doesn't have to use variants. (Have you looked at what format
actually does under the hood? it's kinda scary!)
The major advantage of format
is that it lets you make a single string and store it somewhere, such as in a text file or a resourcestring, and gather other parameters later. This makes it useful for more complex tasks. But if all you need to do is stick two strings together, it's kinda overkill IMO.