Conditionless Switch Cases

Mert

Member
This is really handy in Golang. An example:

Code:
switch {

case speed<10:
//...

case name == "Miller":
//...

default:
//...

}
This is just a suggestion, and may not be important: But surely looks better instead of if else blocks.
Would this feature be good to send a suggestion request to Yoyogames?
 

FrostyCat

Redemption Seeker
No, this is a functionality that YoYo got rid of on purpose in GMS 1 to allow optimization of switch blocks as jump tables. They aren't likely to backtrack on it, especially given the possibility of if-else-if ladders.
 

Mercerenies

Member
Seems like an odd thing to remove for optimization purposes. They should still be able to optimize the common use case (enums, ints, etc.) while allowing switch with no value unoptimized. The two forms are distinguishable at the syntax level, so it's not like there's ever any ambiguity, and a lot of languages these days allow it in some form or another: Go, Ruby, Erlang, Rust, Scala, every Lisp in the book, etc.
 
Top