2016-12-20 7 views
4

as Stringキャストを取り除くにはどうしたらいいですか?<K,V>の<K,V>タイプを指定してください

私は何をしたいことは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 
} 

答えて

5

を含めます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 
} 
関連する問題