UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Project 16, part 2 : Understanding Swift’s Result type

Forums > 100 Days of SwiftUI

Hello. While walking through this part of the course, I get an error with the fetchData function.

func fetchData(from urlString: String) -> Result<String, NetworkError> { .failure(.badURL) }

I get the following messages

Cannot specialize non-generic type 'Result'
Cannot infer contextual base in reference to member 'badURL'

Is there anything wrong in the code or the way to use Result type ?

2      

Do you have a type called Result defined somewhere that could be interfering with the built-in Result?

2      

Yes! I had a 'struct Result' somewhere else. I've renamed it, problem fixed. Thanks a lot for your help.

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.