Created
June 13, 2021 21:19
-
-
Save mhijack/6aede154bba3c2e672a29b386ceb7178 to your computer and use it in GitHub Desktop.
This file contains 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 MarshallSpeaker: View { | |
var maximumVolume: Int = 100 | |
@State var volume: Int = 50 | |
var body: some View { | |
// UI code | |
} | |
public func updateVolume(volume: Int) { | |
self.volume = volume < maximumVolume ? volume : maximumVolume | |
} | |
} | |
let MarshallSpeakerBefore = MarshallSpeaker(volume: 50) | |
MarshallSpeakerBefore.updateVolume(volume: 80) | |
// Above statement generates a view with the new value | |
let MarshallSpeakerAfter = MarshallSpeaker(volume: 80) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment