-
-
Notifications
You must be signed in to change notification settings - Fork 671
Support more types in switch conditions #648
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Hmm, I've never encountered switching on a floating point number before. I'm not sure it's well specified since floating point equality is not precise. I would switch to using if/elses. |
That's what I ended up doing, but seems like the switch should use the same underlying equality check (probably using ==). But even with conditionals, I'm having problems with the above code, I'm porting the code (and its tests) from JS to AS, but in AS I'm getting different values, and the tests are failing. |
You could rewrite it to: switch (true) {
case max == r:
hue = (g - b) / delta + (g < b ? 6 : 0)
break
case max == g:
hue = (b - r) / delta + 2
break
case max == b:
hue = (r - g) / delta + 4
break
} |
+1 for supporting switch/case with string values |
Uh oh!
There was an error while loading. Please reload this page.
I've got some variables all of the same type, and I'm trying to use them in a switch, something like:
but it result in an error like
Here's the whole code:
and the error output:
The text was updated successfully, but these errors were encountered: