我怎样才能摆脱这些as String转换?
我想要做的是改变fun的定义,但我不知道怎么做.将String包括在其中
parametersOf("appKey" to "asdas3334", "token" to "433432")
/**
* Returns a new [Parameters] with the specified contents, given as a list of pairs
* where the first component is the key and the second is the value.
*/
fun <K, V> parametersOf(vararg pairs: Pair<K, V>): Parameters {
val p = Parameters(pairs.size)
for ((key, value) in pairs)
p.put(key as String, value as String)
return p
}发布于 2016-12-20 21:55:42
只需去掉泛型定义并使用Pair<String, String>:
fun parametersOf(vararg pairs: Pair<String, String>): Parameters {
val p = Parameters(pairs.size)
for ((key, value) in pairs)
p.put(key, value)
return p
}https://stackoverflow.com/questions/41251841
复制相似问题