I think it depends on the usage. If you're using it in a place where you might add extra info surrounding it, then the string template is better. However, if you're just using
toString()
as a transformation (I don't have a better way of explaining it lol) then it's better. Generally string template is just better lol!
as long as your dealing with single variables, I can see why you use the second approach, but once you concatenate strings, it really starts to look neat!
Dont forget that you can use raw/multiline Strings as well.
val mockServerUrl = "${if (isSecure) "https" else "http"}://$host:$port"
s
Stephan Schröder
08/29/2023, 9:20 AM
@Klitos Kyriacou I know I could do it, but I don't like control flow within Strings templates. This deterioates the readability of the String Template to a point where I prefer