Jaimesh Patel Jaimesh Patel - 2 years ago 113
Swift Question

Binary operator '&&' cannot be applied to two 'Int' operands

I wanted to check for below values firstName and lastName. But Swift will not allowing me to access. It is giving error like "Binary operator '&&' cannot be applied to two 'Int' operands".

if firstName.length && lastName.length {


Answer Source

In Swift you cannot check for non-null like in C and Objective-C, you have to write

if firstName.length > 0 && lastName.length > 0 { }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download