Pages: [1]   Go Down
Author Topic: "switch quantity not an integer"?  (Read 2615 times)
0 Members and 1 Guest are viewing this topic.
Allentown, PA
Offline Offline
Karma: 0
Posts: 39
Make it so!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In comparing the documentation at, it doesn't say anything about the case statement requiring an integer. I tried using a float and it complained that it wasn't an integer. Can I not use a float? (If so, could a mention be made on the reference page for others to clarify that. :-)

Also, can an operator be used in a case? For example

switch (time) {
  case >300:
    do something;
  case >200:
    do something else;

Offline Offline
Faraday Member
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you can't use a float or an expression in a switch statement.

I'd recommend a set of if/else blocks.



Pages: [1]   Go Up
Jump to: