teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

すぺるみす

2018/03/28 14:52

投稿

MasakiHori
MasakiHori

スコア3391

answer CHANGED
@@ -2,18 +2,18 @@
2
2
 
3
3
  in Swift
4
4
  ```swift
5
- struct Stump {
5
+ struct Stamp {
6
6
 
7
- enum StumpType {
7
+ enum StampType {
8
8
  case a
9
9
  case b
10
10
  case failure
11
11
  }
12
12
 
13
13
  let date: Int
14
- let type: StumpType
14
+ let type: StampType
15
15
 
16
- init?(date: Int, type: StumpType) {
16
+ init?(date: Int, type: StampType) {
17
17
 
18
18
  guard case 0..<7 = date else {
19
19
 
@@ -25,7 +25,7 @@
25
25
  }
26
26
  }
27
27
 
28
- extension Stump: CustomStringConvertible {
28
+ extension Stamp: CustomStringConvertible {
29
29
 
30
30
  var description: String {
31
31
  switch self.type {
@@ -36,9 +36,9 @@
36
36
  }
37
37
  }
38
38
 
39
- struct RandomStumpType: Sequence, IteratorProtocol {
39
+ struct RandomStampType: Sequence, IteratorProtocol {
40
40
 
41
- func next() -> Stump.StumpType? {
41
+ func next() -> Stamp.StampType? {
42
42
 
43
43
  switch arc4random_uniform(3) {
44
44
  case 0: return .a
@@ -49,8 +49,8 @@
49
49
  }
50
50
  }
51
51
 
52
- zip(Array(0..<7), RandomStumpType())
52
+ zip(Array(0..<7), RandomStampType())
53
- .flatMap { Stump(date: $0.0, type: $0.1) }
53
+ .flatMap { Stamp(date: $0.0, type: $0.1) }
54
54
  .forEach { print($0) }
55
55
 
56
56
  ```