This article aims to introduce Scala's less common symbolic meanings in other languages and to help understand Scala Code.
As I learn more about Scala, I will continue to add the content of this blog post, which describes the symbols in Scala:
- ::: Three colon operator: A connection operation that represents a list
Val one = list (All-in-one) Val-the-list (4,5,6) val three = One:::two
Output result: Three:list[int] = List (1, 2, 3, 4, 5, 6)
- :: Two colon operator: A connection operation that represents a normal element to a list
- _n underscore number operator: used to access the nth element of a tuple, the value of n starts at 1. The tuple's element access method differs from the array because the tuple's element type can be different.
- ->: Returns a two-element group
Val four = one and one
return: (List[int], list[int]) = (List (1, 2, 3), List (4, 5, 6))
- <-: Used to traverse collection objects
- =>: Change the left thing to the right thing; it can be seen as the syntax sugar for creating a function instance, which is commonly found in the following three types:
- =>:example:int = string indicates that the function input is of type Int and returns a string type, same function (int,string)
- () =>:example: () = = T means that the function has no input parameters, but returns t
- Unit=>:unit is equivalent to a value of no value, equivalent to void in C + +
- _: There are many meanings, 1, wildcard 2, anonymous function
- _*:sequence xs passed as multiple parameters to F (ys:t*)
Reference documents
1 Http://stackoverflow.com/questions/6951895/what-does-and-mean-in-scala
2 http://docs.scala-lang.org/tutorials/FAQ/finding-symbols.html
Symbolic meanings of common but uncommon (other languages) in Scala