Skip to content

Instantly share code, notes, and snippets.

@SebastianBoldt
Created February 3, 2022 16:05
Show Gist options
  • Save SebastianBoldt/e15651f4f91910f57124bbc8d02e27d3 to your computer and use it in GitHub Desktop.
Save SebastianBoldt/e15651f4f91910f57124bbc8d02e27d3 to your computer and use it in GitHub Desktop.
let task = Task { () -> String in
let text = try await requestTextFromServer()
return text
}
let result = try await task.result
switch result {
case let .success(value):
print(value)
case let .failure(error):
print(error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment