In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "A brief introduction to collections in Scala". In daily operation, I believe that many people have doubts about the simple introduction of collections in Scala. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "simple introduction to collections in Scala". Next, please follow the editor to study!
# # tuple
Declare a tuple and surround the elements of multiple tuples in parentheses. When you need to access the value of an element in a tuple, you can do so in ways like tuple.1, tuple.2, and tuple._3.
Scala > val t = (1, "2", 3. 5) t: (Int, String, Double) = (1 Int, String, Double) scala > println (t. Bike 1) 1scala > println (t. Tape 2) 2scala > println (t.
# # Set
A set is a collection of non-repeating elements. The elements in the list are organized in the order in which they are inserted, but the elements in the set do not record the insertion order of the elements, but organize the values of the elements in a "hash" method, so it allows you to find an element quickly.
Sets include mutable sets and immutable sets. Immutable sets are created by default, and we usually use immutable sets.
If you want to declare a variable set, you need to introduce the scala.collection.mutable.Set package
Var s = Set (1, 3, 3, 7) println (s)
# # Option
Var x:Option [Int] = Some (1) println (x) at this point, the study on "A brief introduction to sets in Scala" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.