@@ -16,7 +16,9 @@ do the values for `integral` below come from?
16
16
scala> import scala.math._
17
17
import scala.math._
18
18
19
- scala> def foo[T](t: T)(implicit integral: Integral[T]) {println(integral)}
19
+ scala> def foo[T](t: T)(implicit integral: Integral[T]): Unit = {
20
+ println(integral)
21
+ }
20
22
foo: [T](t: T)(implicit integral: scala.math.Integral[T])Unit
21
23
22
24
scala> foo(0)
@@ -68,7 +70,9 @@ explicitly, which is how one uses `breakOut`, for example (see question about
68
70
In this case, one has to declare the need for an implicit, such as the ` foo `
69
71
method declaration:
70
72
71
- def foo[T](t: T)(implicit integral: Integral[T]) {println(integral)}
73
+ def foo[T](t: T)(implicit integral: Integral[T]): Unit = {
74
+ println(integral)
75
+ }
72
76
73
77
### Implicit conversions as implicit parameters
74
78
@@ -159,13 +163,13 @@ Let's give examples for them.
159
163
160
164
implicit val n: Int = 5
161
165
def add(x: Int)(implicit y: Int) = x + y
162
- add(5) // takes n from the current scope
166
+ add(5) // takes n from the current scope, res: Int = 10
163
167
164
168
### Explicit Imports
165
169
166
170
import scala.collection.JavaConversions.mapAsScalaMap
167
171
def env = System.getenv() // Java map
168
- val term = env("TERM") // implicit conversion from Java Map to Scala Map
172
+ val term = env("TERM") // implicit conversion from Java Map to Scala Map
169
173
170
174
### Wildcard Imports
171
175
@@ -196,7 +200,7 @@ example:
196
200
for {
197
201
x <- List(1, 2, 3)
198
202
y <- Some('x')
199
- } yield, (x, y)
203
+ } yield (x, y)
200
204
201
205
That expression is translated by the compile into
202
206
0 commit comments