I’m writing the code snippet from memory, so I apologize if it does not properly compile. As far as I remember I run multiple times into this odd issue. In my codebases I set a fixed line width of 100 characters and start wrapping code into next lines if it’s exceeded.
In that sense if I have multiple arrays or string literals which I would like to merge, I start moving the +
concatenation operation into next lines. However this seems to be swallowed by the compiler.
Func(): string = {
Result := "first line"
+ "\nsecond line"
+ "\nthrid line"
# etc.
return Result
}
As far as I remember scenarios like this always resulted into only the first value being added to the result.
Workarounds:
Func(): string = {
Result := "first line" + "\nsecond line" + "\nthrid line" # etc.
return Result
}
Func(): string = {
var Result: string = "first line"
set Result += "\nsecond line"
set Result += "\nthrid line"
# etc.
return Result
}
The first workaround might not always be suitable as it could easily exceed the previously mentioned line width.
This is a critical issue as it’s extremely easy to miss und totally unintuitive. Missing string parts is relatively harmless, but missing array elements can lead to unexpected program behavior and bugs.