TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.