5

I'm working through the Swift tutorial and at one point, an if condition is evaluated where a comma , separates two conditions. Is this the same like an AND operator? As in:

var a = 3
var b = 6

var c = 9
var d = 15

if a < b &&  d > c {
    print("yes")
}

if a < b,  d > c {
    print("yes")
}

Both cases return yes.

TMOTTM
  • 3,286
  • 6
  • 32
  • 63
  • similar, not the exactly same – Sulthan Sep 17 '17 at 10:02
  • I was trying to find an explanation in the guidelines but commas are discussed only in switch statements, not if clauses. Can you point me to this? – TMOTTM Sep 17 '17 at 10:07
  • For one thing, the precedence of `&&` and `,` is different, therefore they are not the same. I am sure there is already a duplicate question but I am unable to find it right now. – Sulthan Sep 17 '17 at 10:10

0 Answers0