The problem with raw strings comes from your editors and IDEs, as they will want to
add whitespace to keep the code aligned. In the middle of a raw string, that whitespace
becomes part of the string itself, as you will see if you run this snippet and
look at the output of the first println()
call.
trimMargin()
is a function available on String
that removes whitespace up
to a particular margin character, whether the default pipe (|
) or a character
that you supply.
You can learn more about this in:
Tags: