[swift-evolution] [Idea] Wrap switch cases in curly braces

Brandon Knope bknope at me.com
Thu Jul 7 15:24:38 CDT 2016


When each case only takes up one line, it may look nice and concise. But what happens in the common case when your case takes up more lines and you indent your braces?

> switch x {
> case 0 { print(0) }
> case 1 { print(1) }
> case 2 { print(2) }
> default { print("other”) }
> }

switch x {
case 0 { 
    print(0) 
}
case 1 { 
    print(1) 
}
case 2 { 
    print(2)
}
default { 
    print("other”) 
}
}

I think this looks much heavier and harder to read.  All the braces detract from the important stuff

Brandon 



> 
> The colon syntax evokes a label, but the modern, complex `case` statements in Swift don’t act much like labels.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160707/7ead24b7/attachment.html>


More information about the swift-evolution mailing list