Hi,
Is there any plan of what is to be done before the first release? I think it would be good to see what major features or issues are pending this may not include any dates.
Hi,
Is there any plan of what is to be done before the first release? I think it would be good to see what major features or issues are pending this may not include any dates.
Release is not so much about issues as at is about validation. Before we call it 1.0 and commit to maintaining backwards compatibility, we want to use Kotlin extensively in production (at JetBrains, and whoever else volunteers), so that we only cast things in stone when they are known to be good.
As of features, here’s a list to give you some idea:
+ plugins performance
and
string template expansion to be available in string returned in function or variable.
So we can have something like
fun stringFromExternalSource() : String{
return “$name is $age year old”
}
val str = stringFromExternalSource().eval(name, age)
.
Thanks a lot for your suggestion, but this is by no means a planned feature.
It's a bummer. Right now in Android all strings should be externalized and having to rely on {0}s and {1}s in xml string is super annoying for translations since the context of the data is lost.
What do you think about this?
``
fun String.replaceAll(vararg r: Pair<String, Any>): String {
var result = this
r forEach {
result = result.replace(it.first, it.second.toString())
}
return result
}
fun main(args : Array<String>) {
val name = “Abc”
val age = 21
val str = “{name} is {age} year old”.replaceAll(“{name}” to name, “{age}” to age)
print(str)
}
And for android You can write:
``
fun Context.getString(resId: Int, vararg r: Pair<String, Any>): String = this.getString(resId).replaceAll(*r)
val str = context.getString(R.string.msg, “{name}” to name, “{age}” to age)
Ah, I didn't realize "to" create Pair. Awesome. Thanks.