blob: 04b90d80e442f441fcc932234fcc83a2a3064575 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
class X(val elem: Int) extends Object {
def foo(y: String): Int = y.length + elem
}
object Functions {
object simple {
val x = new X(2)
val xe = x.elem
val xf: String => Int = x.foo(_: String)
val xf2: String => Int = x.foo(_)
val x2: String => Int = x.foo
val x3 = x.foo _
}
object sams {
abstract class Spore[T, U] {
def run(x: T): U
}
trait Spore2[T, U] { self: Spore2[T, U] =>
def run(x: T): U
}
val x33: String => String = x22 => x22 match {
case "abc" => ""
case x34 => x34
}
val y: PartialFunction[String, String] = x => x match {
case "abc" => ""
case _ => x
}
val z: Spore[String, String] = x => x + x
val z2: Spore2[String, String] = x => x + x
}
}
|