https://kotlinlang.org logo
#announcements
Title
# announcements
n

nimtiazm

11/08/2019, 8:41 PM
In multiline string, is there a way to add newline in literal but not in string itself? I realize it’s possible to do
Copy code
""" …\n """.replace("\n", "")
but i’m looking for a better way
s

Shawn A

11/08/2019, 8:46 PM
If you are using it a lot create an extension function out of it.
n

nimtiazm

11/08/2019, 11:11 PM
so there’s no way other than replacing
Copy code
\n
r

rustyrazorblade

11/09/2019, 4:26 AM
What else would you want it to do?
b

Benjamin Charais

11/09/2019, 5:02 AM
Could you provide some more examples of what you mean?
n

nimtiazm

11/09/2019, 8:40 AM
what i mean to ask is, do we have something similar to trimMargin which omit margin chars.
i’m already using an extension method. was only wondering if i’m missing something that’s already available in stdlib
b

Benjamin Charais

11/10/2019, 7:00 PM
If I am understanding correctly there’s the option to
x.trimMargin("\\n")
22 Views