[英]Scala read two integers at the same time error
I have the following code for reading 2 integers: 我有以下代码可读取2个整数:
Array(N, Q) = readLine.split(" ").map(_.toInt)
For this, I am getting the following error: 为此,我收到以下错误:
error: value update is not a member of object Array
If I do 如果我做
val Array(N, Q) = readLine.split(" ").map(_.toInt)
I get: 我得到:
error: not found: value N
If I declare them before: 如果我之前声明过它们:
val N, Q
I get: 我得到:
!error: '=' expected but ';' found.
So how can I read these integers at the same time? 那么,如何同时读取这些整数?
Don't capitalize the variable names. 不要大写变量名。
scala> val Array(n, q) = Array(1, 2)
n: Int = 1
q: Int = 2
Scala pattern matching special-cases identifiers starting with capital letters. Scala模式匹配以大写字母开头的特殊情况标识符。
Related questions: 相关问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.