码迷,mamicode.com
首页 > 其他好文 > 详细

=>(scala)

时间:2017-09-20 10:30:17      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:instance   eating   func   tac   code   expr   lua   effect   exp   

1Function<n>[A[,B,...],T]  :a function that takes parameters of type A[,B...], and returns a value of type T.

2=>()  :A function that returns Unit is also known as a procedure, normally a method that‘s called only for its side effect.

3f(param: => T)  :it‘s a "by-name parameter", meaning that is evaluated every time it‘s used within the body of the function, and not before. Ordinary "by-value" parameters are evaluated before entry into the function/method.

5case x => y  :separate the pattern (and optional guard) from the result expression

 

=> is syntactic sugar for creating instances of functions. Recall that every function in scala is an instance of a class.

val f: Function1[Int,String] = myInt => "my int: "+myInt.toString
val f2: Int => String = myInt => "my int v2: "+myInt.toString

f: (Int) => String = <function1>
 

=>(scala)

标签:instance   eating   func   tac   code   expr   lua   effect   exp   

原文地址:http://www.cnblogs.com/yumanman/p/7559085.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!