In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to define and declare Scala functions. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Syntax:
Dcl:: = "def" FunDcl
FunDcl:: = FunSig: Type
Def:: = "def" FunDef
FunDef:: = FunSig [":" Type] "=" Expr
FunSig:: = id [FunTypeParamClause] ParamClauses
FunTypeParamClause:: = "[" TypeParam {"," TypeParam} "]"
ParamClauses:: = {ParamClauses} [nl] "("implicit" Params ")"]
ParamClause:: = [nl] "(" [Params] ")"}
Params:: = Param {"," Param}
Param:: = {Annotation} id [":" ParamType]
ParamType:: = Type
| | "= >" Type |
| | Type "*" |
The function declaration has the form: def f psig: T.J. F is the name of the function, psig is the parameter signature, and T is the return type. The function definition def f psig: t = e also includes the function body e, such as an expression that defines the result of the function. The parameter signature consists of an optional type parameter clause [tps], followed by zero or more value parameter clauses (ps1). (psn) composition. Such a declaration or definition introduces a value that has a (possibly polymorphic) method type whose parameter type and return type have been given.
The type of the given function body is expected to be consistent with the return type declared by the function. If the function definition is not recursive, the return type can be omitted because it can be inferred from the type packaged by the function body.
The type parameter clause tps consists of one or more type declarations in which type parameters that may have boundaries are introduced. The field of the type parameter includes the entire signature, as well as any type parameter boundary and the function body, if any.
The value parameter clause ps consists of zero or more canonical type bindings, such as x: t, that bind value parameters and associate them with their types. The scope of a canonical value parameter named x is the function body (if any). All type parameter names and value parameter names must be different.
The above is how to define and declare the Scala function. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
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.