質問編集履歴
4
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,10 +24,14 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
+
#### Seqだとうまくいく
|
28
|
+
|
27
29
|
```scala
|
28
30
|
|
29
|
-
//
|
31
|
+
// OK
|
30
32
|
|
31
33
|
val seq = List(1,2,3,4,2).toSeq.map(n => n + 1)
|
32
34
|
|
33
35
|
println(seq)
|
36
|
+
|
37
|
+
```
|
3
補足説明
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,3 +21,13 @@
|
|
21
21
|
```
|
22
22
|
|
23
23
|
どういう理屈でこのような違いが出るのでしょうか?
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
```scala
|
28
|
+
|
29
|
+
// Seqだとうまくいく
|
30
|
+
|
31
|
+
val seq = List(1,2,3,4,2).toSeq.map(n => n + 1)
|
32
|
+
|
33
|
+
println(seq)
|
2
タイトル修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
scala
|
1
|
+
scala メソッドチェーンができない理由
|
test
CHANGED
File without changes
|
1
内容修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,13 +2,19 @@
|
|
2
2
|
|
3
3
|
```scala
|
4
4
|
|
5
|
+
// エラー
|
6
|
+
|
5
|
-
val list = List(1,2,3,4,2).toSet.map(n => n + 1)
|
7
|
+
val list = List(1,2,3,4,2).toSet.map(n => n + 1)
|
8
|
+
|
9
|
+
println(list)
|
6
10
|
|
7
11
|
|
8
12
|
|
13
|
+
// OK
|
14
|
+
|
15
|
+
val list = List(1,2,3,4,2)
|
16
|
+
|
9
17
|
val set = list.toSet
|
10
|
-
|
11
|
-
|
12
18
|
|
13
19
|
println(set.map(n => n + 1)
|
14
20
|
|