I don't get the part with Metropolis... If place is a constant, we can't change it's value, right? So how is switch able to change it's value from Metropolis to Gotham, Mega-City One etc?
if you did not figure it out yourself place indeed cant be changed, and he did not do that either, the switch case would always just print the default case in the above example ("Who are you") The switch case just detects which value "place" has in the moment its called, so you can do different things depending on what the actual value of place is if you somehow changed the value of place laterwards (which you cant with a constant) and place would have the value "Gotham", always only ("Youre Batman") would be printed out
That was the best explanation I’ve heard. Thanks.
I don't get the part with Metropolis... If place is a constant, we can't change it's value, right? So how is switch able to change it's value from Metropolis to Gotham, Mega-City One etc?
if you did not figure it out yourself
place indeed cant be changed, and he did not do that either, the switch case would always just print the default case in the above example ("Who are you")
The switch case just detects which value "place" has in the moment its called, so you can do different things depending on what the actual value of place is
if you somehow changed the value of place laterwards (which you cant with a constant) and place would have the value "Gotham", always only ("Youre Batman") would be printed out
If you've never heard this song... the end of this tutorial is going to be so weird!
😆
It was an *excellent* example however!
Except the number of gifts decrease in thus example, but increases in the song.
Why use enum ????
He explained why.