Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
when the swift language cannot infer the generic type from the invocation, it also doesn't want you to explicily specify generic type in the bracket...
says i have a method:
```
func createDeferred<T>() -> ABC.XYZ.Deferred<T>
```
then if you call it like this:
```
let dfd = createDeferred()
```
It complaints that it cannot infer generic type T, which make sense.
But it also doesn't want you to code it this way:
```
let dfd = createDeferred<Int>("countProperty")
```
if you do so, it mumbles gibberish: "Cannot explicitly specialize a generic function".
What it actually trying to say is, you should put the type somewhere else so that it can show off its smartness to "infer" it from there:
```
let dfd: ABC.XYZ.Deferred<Int> = createDeferred()
```
with a few more typing and findout what exact type it is, it finally works.
the moral of the story is, in order to communicate with the wonderful work apple genius made, you don't tell it what is the answer straight away, that's defiance, you must hide the answer somewhere intricately and let the smarty swifty swift to find it out for you.
rant