Symbolic meanings of common but uncommon (other languages) in Scala

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.