回答編集履歴
3
補足
answer
CHANGED
@@ -53,9 +53,10 @@
|
|
53
53
|
|
54
54
|
----
|
55
55
|
|
56
|
-
|
56
|
+
おまけですが、4のような`a..b().c()`を使いたいケースを考えてみました...
|
57
57
|
|
58
58
|
```
|
59
59
|
var _list = <List<String>>[['one', 'two', 'three'],['four', 'five', 'six']];
|
60
60
|
print(_list..first.shuffle());
|
61
|
+
print((_list..shuffle()..first.shuffle()).first.first);
|
61
62
|
```
|
2
余談を追加
answer
CHANGED
@@ -49,4 +49,13 @@
|
|
49
49
|
|
50
50
|
> It helps to think of ".." as not really an operator, but more like a scoping construct (like parentheses). It creates a new scope from the ".." to either the next "..", or the first other scope delimiter (";", ")", "}" or similar).
|
51
51
|
|
52
|
-
> Basically, a..b().c() is the same as (t){t.b().c(); return t;}(a)
|
52
|
+
> Basically, a..b().c() is the same as (t){t.b().c(); return t;}(a)
|
53
|
+
|
54
|
+
----
|
55
|
+
|
56
|
+
余談ですが、4のような`a..b().c()`を使いたいケースを考えてみました...
|
57
|
+
|
58
|
+
```
|
59
|
+
var _list = <List<String>>[['one', 'two', 'three'],['four', 'five', 'six']];
|
60
|
+
print(_list..first.shuffle());
|
61
|
+
```
|
1
補足
answer
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
3の`_list.shuffle().first`は単純に`shuffle()`の戻り値が`void`のため、エラーになります。
|
2
2
|
|
3
|
-
|
3
|
+
4の`_list..shuffle().first`は`shuffle().first`がカスケードの範囲として認識されます。なので、`shuffle()`の戻り値`void`に`first`しており、エラーになります。
|
4
|
-
一方、
|
4
|
+
一方、2の`(_list..shuffle()).first`では`shuffle()`のみがカスケードの範囲として認識されるので、`first`は`_list`に対して実行されます。
|
5
5
|
|
6
6
|
----
|
7
7
|
|
@@ -18,7 +18,7 @@
|
|
18
18
|
}(_list);
|
19
19
|
```
|
20
20
|
|
21
|
-
|
21
|
+
2の`print((_list..shuffle()).first);`は以下のように置き換えられる
|
22
22
|
```
|
23
23
|
print(
|
24
24
|
(arg){
|
@@ -31,7 +31,7 @@
|
|
31
31
|
);
|
32
32
|
```
|
33
33
|
|
34
|
-
|
34
|
+
4の`print(_list..shuffle().first);`は以下のように置き換えられる
|
35
35
|
```
|
36
36
|
print(
|
37
37
|
(arg){
|