You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ERROR AS200: Conversion from type 'f64' to 'u32' requires an explicit cast.
switch (max) {
~~~
in src/as/glas/math/Color.ts(559,11)
ERROR AS200: Conversion from type 'f64' to 'u32' requires an explicit cast.
case r:
~
in src/as/glas/math/Color.ts(560,9)
ERROR AS200: Conversion from type 'f64' to 'u32' requires an explicit cast.
case g:
~
in src/as/glas/math/Color.ts(563,9)
ERROR AS200: Conversion from type 'f64' to 'u32' requires an explicit cast.
case b:
~
in src/as/glas/math/Color.ts(566,9)
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.
Activity
willemneal commentedon Jun 12, 2019
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.
trusktr commentedon Jun 13, 2019
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.
MaxGraey commentedon Jun 13, 2019
You could rewrite it to:
[-]switch statement has unexpected type error[/-][+]Support more types in switch conditions[/+]ColinEberhardt commentedon Dec 8, 2020
+1 for supporting switch/case with string values