8000 added two missing line breaks · AYCS/scala.github.com@026ac09 · GitHub
[go: up one dir, main page]

Skip to content

Commit 026ac09

Browse files
committed
added two missing line breaks
1 parent 60681ca commit 026ac09

File tree

1 file changed

+2
-< 8000 !-- -->0
lines changed

1 file changed

+2
-0
lines changed

overviews/collections/arrays.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ The `evenElems` method returns a new array that consist of all elements of the a
7575
error: cannot find class manifest for element type T
7676
val arr = new Array[T]((arr.length + 1) / 2)
7777
^
78+
7879
What's required here is that you help the compiler out by providing some runtime hint what the actual type parameter of `evenElems` is. This runtime hint takes the form of a class manifest of type `scala.reflect.ClassManifest`. A class manifest is a type descriptor object which describes what the top-level class of a type is. Alternatively to class manifests there are also full manifests of type `scala.reflect.Manifest`, which describe all aspects of a type. But for array creation, only class manifests are needed.
7980

8081
The Scala compiler will construct class manifests automatically if you instruct it to do so. "Instructing" means that you demand a class manifest as an implicit parameter, like this:
@@ -107,6 +108,7 @@ In both cases, the Scala compiler automatically constructed a class manifest for
107108
evidence parameter of type ClassManifest[U]
108109
def wrap[U](xs: Array[U]) = evenElems(xs)
109110
^
111+
110112
What happened here is that the `evenElems` demands a class manifest for the type parameter `U`, but none was found. The solution in this case is, of course, to demand another implicit class manifest for `U`. So the following works:
111113

112114
scala> def wrap[U: ClassManifest](xs: Array[U]) = evenElems(xs)

0 commit comments

Comments
 (0)
0