Jason5lee
01/05/2022, 12:25 PM"something${somelogic}something${somelogic}"
. But it ends up being too long for a line. Any tips to rewrite to make the line shorter but still being conscious of how the string is built?Ivan Zinchenko
01/05/2022, 12:28 PM"""
strings and trim newlines.Ivan Zinchenko
01/05/2022, 12:34 PM>>> val somelogic = "somelogic"
>>> """something
... $somelogic
... something
... $somelogic
... something""".replace("\n","")
res22: kotlin.String = somethingsomelogicsomethingsomelogicsomething
Ivan Zinchenko
01/05/2022, 12:36 PMfun String.removeNewlines():String = replace("\n","")
>>> """something
... $somelogic
... something""".removeNewlines()
res28: kotlin.String = somethingsomelogicsomething
Klitos Kyriacou
01/05/2022, 2:57 PM"something"
+ somelogic
+ "something"
+ somelogic
Ruckus
01/05/2022, 4:08 PMbuildString {
append("something")
append(someLogic)
append("something")
append(someLogic)
}
Which also has the added benefit that you can split out some of the someLogic
parts onto their own lines for clarity.