Swift: Change switch/case to given/when

Originator:t.grimwoodtaylor
Number:rdar://17221434 Date Originated:08-Jun-2014
Status:Open Resolved:
Product:OS X Product Version:
Classification:Enhancement Reproducible:Not Applicable
 
I find Perl 6's use of given/when rather than switch/case reads much more naturally.

given number {
    when 1, 2, 3: ...
    when range: ...
    default: ...
}

reads much more naturally than

switch number {
    case 1, 2, 3: ...
    case range: ...
    default: ...
}

I can see consistency with other languages as the only reason to choose a construct that reads much less nicely than this alternative. Since Swift does away with many past behaviours such as no fall through in switch statements and mandatory braces on if statements, I don't think renaming this construct would be a problem and would make for much more natural sounding code.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!