Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何定义一个包含一个整数和三个只有 20 个元素的字符串的数组并用零填充整数?
我试过但没有成功:
val a = Array [(Int,String,String,String)].fill(20)(0)
填充答案很好,但值得在这里说的是,当您处于 4 元组时,您的代码清晰度几乎肯定会通过案例类得到改善。尤其如此,因为您的三个字段是字符串,这将很容易混淆哪个字段的含义。
尝试这样的事情: -
Array.fill(20)((0,"","",""))