我正在从超技能中学习科特林。
我很好奇是否可以分配componentN运算符来重复执行如下功能:
val (a, b, c) = repeat(3) { BigInteger(readLine()!!) }
我曾尝试使用componentN
运算符扩展某些功能,但我不知道如何使用repeat
进行扩展>
我正在从超技能中学到Kotlin。我很好奇是否可以分配componentN运算符来重复函数,如:val(a,b,c)= repeat(3){BigInteger(readLine()!!)}我已经尝试过...
repeat
不返回任何内容,这意味着您不能对destructuring declarations使用此功能。您可以将Range
与map
,List
或Array
结合使用: