1 2 3 4 5 6 7 8 | byte b = 1 switch(b) { case 0..9: println 'it is between 0 and 9' break default: println 'it is something else' } |
It executes 'default' part, not the part with 0..9, which is not what a programmer would typically expect.
The reason behind it should be related to type conversion between "byte" and "int" types. With the following workaround:
1 | swtch((int)b) |
the program executes "proper" case.
Комментариев нет:
Отправить комментарий