This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct TotalPricePreferenceKey: PreferenceKey { | |
| static var defaultValue: Double = 0.0 | |
| static func reduce(value: inout Double, nextValue: () -> Double) { | |
| value += nextValue() | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ✅ struct KeyColorPreferenceKey: PreferenceKey { | |
| static var defaultValue: Color = .white | |
| static func reduce(value: inout Color, nextValue: () -> Color) { | |
| value = nextValue() | |
| } | |
| } | |
| struct ContentView: View { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import DequeModule | |
| struct Stack<T> { | |
| private var deque: Deque<T> = [] | |
| var top: T? { deque.last } | |
| mutating func push(_ element: T) { | |
| deque.append(element) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Stack<T> { | |
| private var array: [T] = [] | |
| var top: T? { array.last } | |
| mutating func push(_ element: T) { | |
| array.append(element) | |
| } | |
| mutating func pop() -> T? { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import RegexBuilder | |
| let regex = Regex { | |
| "Hi, WWDC" | |
| Capture { | |
| Repeat(.digit, count: 2) | |
| } | |
| "!" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import RegexBuilder | |
| let regex = Regex { | |
| "Hi, WWDC" | |
| Repeat(.digit, count: 2) | |
| "!" | |
| } | |
| let input = "Hi, WWDC21! Hi, WWDC22! Hi Hello" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import RegexBuilder | |
| let regex = Regex { | |
| "Hi, WWDC" | |
| Repeat(.digit, count: 2) | |
| "!" | |
| } | |
| let input = "Hi, WWDC21! Hi, WWDC22! Hi Hello" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import RegexBuilder | |
| let regex = Regex { | |
| "Hi, WWDC" | |
| Repeat(.digit, count: 2) | |
| "!" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) | |
| extension Regex { | |
| public init<Content>(@RegexComponentBuilder _ content: () -> Content) where Output == Content.RegexOutput, Content : RegexComponent | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let regex = /Hi, WWDC\d{2}!/ |
NewerOlder