Created
October 22, 2025 12:28
-
-
Save jacobsapps/9445d9779c2136308602d4ca6be20a7f to your computer and use it in GitHub Desktop.
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
| enum User { | |
| @TaskLocal static var name = "n/a" | |
| } | |
| Task { | |
| print(User.name) // n/a | |
| User.$name.withValue("Alice") { | |
| print(User.name) // Alice | |
| Task { | |
| print(User.name) // Alice | |
| User.$name.withValue("Bob") { | |
| print(User.name) // Bob | |
| } | |
| print(User.name) // Alice | |
| } | |
| print(User.name) // Alice | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment