SWIFT Advanced Mode Matching if Case

share picture

let age = 22
let sex = “girl”

if (sex == “girl” && age >= 18 && age <= 25){
print(“girl”)
} else {
print(“Go you”)
}

A new syntax has been added for us in swift2: if case

if case 18…25 = age {
print(“free”)
} else {
print(“without”)
}

You can add conditions through where

Of course it is not needed, swift2 provides us with the syntax of conditional filtering: where

if case 18…25 = age where sex == “girl”{
print(“Yes, Old Iron”)
} else {
print(“Let’s go”)
}

[swift] if case, guard case, for case
Reference: https:/ /www.jianshu.com/p/dc42bdbbf473

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4125 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.