This commit is contained in:
Onoshko Dan 2014-05-30 01:49:27 +07:00
parent e7c016fae8
commit 945967cdc7

View File

@ -308,12 +308,12 @@ As in CoffeeScript, you can use `chained comprassions`:
`inline switch` and `switch without expression`: `inline switch` and `switch without expression`:
String grade = switch { String grade = switch {
when score < 60: 'F' when score < 60: 'F';
when score < 70: 'D' when score < 70: 'D';
when score < 80: 'C' when score < 80: 'C';
when score < 90: 'B' when score < 90: 'B';
default: 'A' default: 'A';
} };
As you see, you can use keyword `when`, it's like `case`, but if the condition is satisfied, `switch` will `break`. As you see, you can use keyword `when`, it's like `case`, but if the condition is satisfied, `switch` will `break`.