`joinToString` not being inline has been a (rather...
# stdlib
y
joinToString
not being inline has been a (rather mild) inconvenience for me. Is there a reason why it isn't? I know that the stdlib is using a default value of
null
for the transform lambda, but couldn't it just use
it.toString()
?
1
k
I'm surprised that the implementation missed an opportunity to avoid having to call
toString()
for non-String elements. A
StringBuilder
can have numbers appended directly to it without building a String first, but
joinToString
nevertheless creates intermediate Strings.
d
I think
joinToString
is called rarely enough that having a
toString
call within the lambda isn't much boilerplate while confirming that you're using the right object and intend to turn it into a string. Compare that to
StringBuilder
, where you may regularly add multiple primitive values in a row and the code becomes mostly
toString
calls.