I'm trying to find out if there is an easy way to preserve indentation of interpolated variables when using multi-line string.
let nested = """ foo bar """ let nestedIndented = """ baz qux """ let string = """ Hello \(nested) \(nestedIndented) Bye """ print(string)
Hello foo bar baz qux Bye
Hello foo bar baz qux <-- qux is not indented Bye
This can be solved by pre-indenting nested strings, before interpolating them in the final output. But this would require nested strings to be aware of the context where they would be nested, which is not desirable.
Any ideas or suggestions?