How to concatenate / add 2 lines to kotlin?

I am trying to combine Intwith Stringin such a way that the conclusion is String, but not sure how to do it.

Here is my code:

val myMessage = context.getString(R.string.mymessage)

where myMessageis the string.

Now I want to add Int, which is it.myinfo.codeid.

+6
source share
2 answers

You can use string patterns :

"${context.getString(R.string.mymessage)} ${it.myinfo.codeid}"
+13
source

Use +as you know in Java:

context.getString(R.string.mymessage) + " " + it.myinfo.codeid

or use a more idiomatic approach to templates:

"${context.getString(R.string.mymessage)} ${it.myinfo.codeid}"
+1
source

All Articles