Hi!
I was thinking the other day: Why does switch() handle ONLY int-values? Wouldn't it have been really easy to implement at compiler level that all types that have a == operator (which returns a bool) are suitable for switching?
Hi!
I was thinking the other day: Why does switch() handle ONLY int-values? Wouldn't it have been really easy to implement at compiler level that all types that have a == operator (which returns a bool) are suitable for switching?
The OS requirements were Windows Vista Ultimate or better, so we used Linux.
Yes its possible (PHP allows you to switch on pretty much anything) but it would lose a lot of its efficiency. A switch is generally done using a jump table where the value of variable tells you the exact offset to go to which then tells the program where to jump to. A lot more efficent then basically an if else string that it would become if you had non integer types.