Kotlin:是否可以重复使用componentN运算符?

问题描述 投票:0回答:1

我正在从超技能中学习科特林。

我很好奇是否可以分配componentN运算符来重复执行如下功能:

val (a, b, c) = repeat(3) { BigInteger(readLine()!!) }

我曾尝试使用componentN运算符扩展某些功能,但我不知道如何使用repeat进行扩展>

我正在从超技能中学到Kotlin。我很好奇是否可以分配componentN运算符来重复函数,如:val(a,b,c)= repeat(3){BigInteger(readLine()!!)}我已经尝试过...

kotlin repeat
1个回答
0
投票

repeat不返回任何内容,这意味着您不能对destructuring declarations使用此功能。您可以将RangemapListArray结合使用:

© www.soinside.com 2019 - 2024. All rights reserved.