Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM authored Jul 13, 2024
1 parent 41a73d3 commit 36d6694
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,63 @@ enum TestEnum {

### Create a Subtype Enum

<details>
<summary> Click to expand </summary>

```swift
@Enumerator("""
enum Subtype: String {
{{#cases}}
case {{name}}
{{/cases}}
}
""",
"""
var subtype: Subtype {
switch self {
{{#cases}}
case .{{name}}:
.{{name}}
{{/cases}}
}
}
""")
enum TestEnum {
case a(val1: String, val2: Int)
case b
case testCase(testValue: String)
}
```
Is expanded to:
```diff
enum TestEnum {
case a(val1: String, val2: Int)
case b
case testCase(testValue: String)

+ enum Subtype: String {
+ case a
+ case b
+ case testCase
+ }

+ var subtype: Subtype {
+ switch self {
+ case .a:
+ .a
+ case .b:
+ .b
+ case .testCase:
+ .testCase
+ }
+ }
}
```

</details>

### Create Is-Case Properties

<details>
<summary> Click to expand </summary>

Expand Down

0 comments on commit 36d6694

Please sign in to comment.