Why won't swift allow nested if statements along with others? -


so past hour or so, i've been trying nest 3 if statements in swift nothing working. i'm literally pulling hair out seems simple , yet have no idea doing wrong. appreciated.

var population = 125442 var message: string var hasapostoffice: bool = true  if population < 10000 {     message = "\(population) pretty small town" }else if population >= 10000 && population < 50000 {         message = "\(population) medium sized town" }else{         message = "\(population) large town!" }else = {     population >= 200000 && population < 120000 {         message = "\(population) super huge town" } } print(message)  if !hasapostoffice {     print("where buy stamps?") } 

your nested should -

if population < 10000 {     message = "\(population) pretty small town" }else if population >= 10000 && population < 50000 {     message = "\(population) medium sized town" }else if(// condition here){     message = "\(population) large town!" }else {  } 

plus condition

population >= 200000 && population < 120000 { 

in opinion can never true population cannot both less 120000 , more 200000 @ same time.

so check logic here


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -