回答編集履歴
2
update test
answer
CHANGED
@@ -23,4 +23,23 @@
|
|
23
23
|
}
|
24
24
|
}
|
25
25
|
print("numberOfMessages =", numberOfMessages)
|
26
|
+
```
|
27
|
+
|
28
|
+
# test(修正版)
|
29
|
+
|
30
|
+
```swift
|
31
|
+
var countRead = 0, countUnread = 0, countNil = 0
|
32
|
+
news.enumerated().forEach {
|
33
|
+
print($0, $1.listened ?? "nil")
|
34
|
+
if let listened = $1.listened {
|
35
|
+
if listened {
|
36
|
+
countRead += 1
|
37
|
+
} else {
|
38
|
+
countUnread += 1
|
39
|
+
}
|
40
|
+
} else {
|
41
|
+
countNil += 1
|
42
|
+
}
|
43
|
+
}
|
44
|
+
print("count:(news.count) read:(countRead) unread:(countUnread) nil:(countNil)")
|
26
45
|
```
|
1
test
answer
CHANGED
@@ -8,4 +8,19 @@
|
|
8
8
|
|
9
9
|
```swift
|
10
10
|
news.filter {$0.listened == false}.count
|
11
|
+
```
|
12
|
+
|
13
|
+
# test
|
14
|
+
|
15
|
+
```swift
|
16
|
+
var numberOfMessages = 0
|
17
|
+
news.enumerated().forEach {
|
18
|
+
print($0, $1.listened ?? "nil")
|
19
|
+
if let listened = $1.listened {
|
20
|
+
if listened {
|
21
|
+
numberOfMessages += 1
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
print("numberOfMessages =", numberOfMessages)
|
11
26
|
```
|