unwrapping multiple optionals in if statement

前端 未结 8 593
鱼传尺愫
鱼传尺愫 2020-11-28 07:38

I want to unwrap two optionals in one if statement, but the compiler complaints about an expected expression after operator at the password constant. What could be the reaso

8条回答
  •  遥遥无期
    2020-11-28 07:59

    I can't explain why the above code doesn't work, but this would be good a replacement:

    if let email = self.emailField?.text 
    {
        if let password = self.passwordField?.text 
        {
            //do smthg
        }
    }
    

提交回复
热议问题