回答編集履歴
2
update test
test
CHANGED
@@ -49,3 +49,41 @@
|
|
49
49
|
print("numberOfMessages =", numberOfMessages)
|
50
50
|
|
51
51
|
```
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
# test(修正版)
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
```swift
|
60
|
+
|
61
|
+
var countRead = 0, countUnread = 0, countNil = 0
|
62
|
+
|
63
|
+
news.enumerated().forEach {
|
64
|
+
|
65
|
+
print($0, $1.listened ?? "nil")
|
66
|
+
|
67
|
+
if let listened = $1.listened {
|
68
|
+
|
69
|
+
if listened {
|
70
|
+
|
71
|
+
countRead += 1
|
72
|
+
|
73
|
+
} else {
|
74
|
+
|
75
|
+
countUnread += 1
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
} else {
|
80
|
+
|
81
|
+
countNil += 1
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
print("count:(news.count) read:(countRead) unread:(countUnread) nil:(countNil)")
|
88
|
+
|
89
|
+
```
|
1
test
test
CHANGED
@@ -19,3 +19,33 @@
|
|
19
19
|
news.filter {$0.listened == false}.count
|
20
20
|
|
21
21
|
```
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
# test
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
```swift
|
30
|
+
|
31
|
+
var numberOfMessages = 0
|
32
|
+
|
33
|
+
news.enumerated().forEach {
|
34
|
+
|
35
|
+
print($0, $1.listened ?? "nil")
|
36
|
+
|
37
|
+
if let listened = $1.listened {
|
38
|
+
|
39
|
+
if listened {
|
40
|
+
|
41
|
+
numberOfMessages += 1
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
print("numberOfMessages =", numberOfMessages)
|
50
|
+
|
51
|
+
```
|