thye just check for the value of the variable and then do something base on the result ? so what the problem is with my code ?
Not only in go, switch case in every language is meant to check the equality of a variable with a value, not to check whether a value meets some condition or not. Say if you want to see variable animal is dog or cat or any other, using if else ladder you'll be using so many == checks. Instead you can use switch there
Обсуждают сегодня