Skip to content

Commit ff8c3d3

Browse files
Merge pull request #656 from ferhtaydn/fix/type-implicits
fix typos
2 parents 63de5b0 + b3a49e8 commit ff8c3d3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tutorials/FAQ/finding-implicits.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ do the values for `integral` below come from?
1616
scala> import scala.math._
1717
import scala.math._
1818

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+
}
2022
foo: [T](t: T)(implicit integral: scala.math.Integral[T])Unit
2123

2224
scala> foo(0)
@@ -68,7 +70,9 @@ explicitly, which is how one uses `breakOut`, for example (see question about
6870
In this case, one has to declare the need for an implicit, such as the `foo`
6971
method declaration:
7072

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+
}
7276

7377
### Implicit conversions as implicit parameters
7478

@@ -159,13 +163,13 @@ Let's give examples for them.
159163

160164
implicit val n: Int = 5
161165
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
163167

164168
### Explicit Imports
165169

166170
import scala.collection.JavaConversions.mapAsScalaMap
167171
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
169173

170174
### Wildcard Imports
171175

@@ -196,7 +200,7 @@ example:
196200
for {
197201
x <- List(1, 2, 3)
198202
y <- Some('x')
199-
} yield, (x, y)
203+
} yield (x, y)
200204

201205
That expression is translated by the compile into
202206

0 commit comments

Comments
 (0)