Unable to infer complex closure return type; add explicit type to disambiguate

Any suggestion for the other variation please?

Which one do you want?

              shortcut match | shortcut doesn't match
pic is ""    |       1       |           2
pic is not ""|       3       |           4

I'm assuming you want only 3, but that doesn't seem to be the case.

PS
It'd be better if you change category from Development/Compiler to Using Swift. This threads fits better there.

I really don't understand what you mean. Could you please provide some solution? its really very important :(

I don’t understand what you want to do, so it’s hard to concretely suggest something. Does the one with && not work as intended?

Don't really what I exactly what is

if i.groupsShortcut == self.shortcut {
if i.pic != "" {
}
}

Yes, they’re equivalent, or you can simply use 2 ifs, there’s no harm in doing that.

I mean like this:

  VStack(alignment: .leading){
                    
                    ForEach(observedData.datas){i in
                
                        if i.groupsShortcut == self.shortcut{
                         
                            tweetCellTop(name: i.name, id: i.tagId, pic: i.pic, image: i.url, msg: i.msg)
                            if i.pic != ""{
                                tweetCellMiddle(pic: i.pic).padding(.leading, 60)
                            }
                                tweetCellBottom().offset(x: UIScreen.main.bounds.width / 4)
                            
                            
                            
                    }
                        }
                    
                }.padding(.bottom, 15)

I see, you can just do that, there’s no simple way to merge it.

but I am getting error. Is there any way to solve it?

New error? Old error? What does it say?

What does datatype look like?

**import** Foundation

**struct** datatype : Identifiable {

**var** id : String

**var** name : String

**var** msg : String

**var** groupsShortcut : String

**var** retwetts : String

**var** likes : String

**var** pic : String

**var** url : String

**var** tagId : String

}

**struct** Topdatatype : Identifiable {

**var** id : String

**var** tag : String

**var** tweets : String

}

Ok, I thought you already solved the error.

Here’s what you can do. You need to figure out the error first, just remove each part, until the compiler stops complaining, you’ll know that that line is the culprit.

The error is not exactly helping at the moment, so we gotta do it old-style.

The compiler does not complain if I remove the if pic!= ""

As in, finished compiling to the end, or does it have different error?

Its ok if I remove this part but I need this check

I just want to make sure, since there is miscommunication earlier, does it finish the compilation without error if you remove if i.pic != "" part (along with the bracket)?

yes it finishes the compilation without error

This is curious, I’m not sure what could cause this. Could you take a screen shot of the one that successfully compiled? I wanna compare them.

Terms of Service

Privacy Policy

Cookie Policy