File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
docs/docs/reference/new-types Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ use of the match type as the return type):
67
67
def leafElem [X ](x : X ): LeafElem [X ] = x match
68
68
case x : String => x.charAt(0 )
69
69
case x : Array [t] => leafElem(x(9 ))
70
- case x : Iterable [t] => leafElem(x.next() )
70
+ case x : Iterable [t] => leafElem(x.head )
71
71
case x : AnyVal => x
72
72
```
73
73
Original file line number Diff line number Diff line change
1
+ type LeafElem [X ] = X match
2
+ case String => Char
3
+ case Array [t] => LeafElem [t]
4
+ case Iterable [t] => LeafElem [t]
5
+ case AnyVal => X
6
+
7
+ def leafElem [X ](x : X ): LeafElem [X ] = x match
8
+ case x : String => x.charAt(0 )
9
+ case x : Array [t] => leafElem(x(9 ))
10
+ case x : Iterable [t] => leafElem(x.head)
11
+ case x : AnyVal => x
You can’t perform that action at this time.
0 commit comments