In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what are the symbols in scala". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Symbols in Scala:
: three colon operators: indicates the concatenation operation of list
Val one = List (1 and 2) val two = List (4 and 5) val three = one:::two
The output is three: List [Int] = List (1, 2, 3, 4, 5, 6)
:: two colon operators: indicates the join operation between a normal element and a list
The _ N underscore numeric operator: used to access the Nth element of the tuple, the value of N starts at 1. The element access method of a tuple is different from an array because the element type of a tuple can be different.
-> returns a binary tuple
Return: (List [Int], List [Int]) = (List (1,2,3), List (4,5,6))
Change what is on the left to something on the right; it can be seen as a syntax candy for creating an instance of a function. There are three common operators:
= >: Example:Int = > String indicates that the input of the function is int type and string type is returned, which is the same as Function (Int,String)
() = >: Example: () = > T indicates that the function has no input parameters, but returns T
Unit= >: Unit is equivalent to no value, equivalent to Void in C++
_ has many meanings
1. Wildcard characters
Import org.apache.spark.SparkContext._
2. Anonymous function
3. Refer to each element in the collection. For example, filter elements in a list that are greater than a certain value
Val lst = List (1, 2, 3, 4, 5) val lstFilter = lst.filter (_ > 3)
4. Pattern matching can be used to get the team members of a tuple.
Val m = Map (1-> 2 for 2-> 4)
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.