In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail what the role of Array class in Scala language is, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Array class
The generic array class is defined as follows.
Final class Array [A] (len: Int) extends Seq [A] {
Def length: Int = len
Def apply (I: Int): a =.
Def update (I: Int, x: a): Unit =.
Def elements: Iterator [A] =.
Def subArray (from: Int, end: Int): Array [A] =.
Def filter (p: a = > Boolean): Array [A] =.
Def map [B] (f: a = > B): Array [B] =.
Def flatMap [B] (f: a = > Array [B]): Array [B] =.
}
If T is not a type parameter or abstract type, the type Array [T] represents the native array type [] T in the host system. In this case length returns the length of the array, apply represents the subscript, and update indicates the element update. Due to the existence of syntax sugars for apply and update operations (§6.25), the following are the corresponding array xs operations in Scala and Java/C#:
Scala Java/C#
Xs.length xs.length
Xs (I) xs [I]
Xs (I) = e xs [I] = e
Standard reference class
The array also implements the sequence feature scala.Seq and defines the elements method to return an Iterator that contains all the elements in the array.
Because the implementation of an array of parameterized types in Scala is different from that of an array in the host language, you need to pay attention to some minor differences when dealing with arrays. The explanation is as follows.
First of all, unlike arrays in Java or C #, arrays in Scala are not covariant; that is, in Scala, S
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.