What, if anything, is wrong with the following code? void test(int x){ switch(x){ case 1: case 2: case 0: default : case 4: } }
was thinking variable x in switch is not declared since it was only visible within the method
About Question enthuware.ocajp.i.v8.2.1282 :
Moderator: admin
-
- Posts: 2
- Joined: Wed Sep 04, 2019 1:41 am
- Contact:
-
- Site Admin
- Posts: 10383
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1282 :
What happened when you tried to compile it?
-
- Posts: 16
- Joined: Sat Nov 30, 2024 5:27 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1282 :
Hello, not really an issue but just want to have your thoughts.
The fact that "case 1: 1" is not allowed for new switch expression (missing yield) but "case 1: method()" is allowed is really weird Why did they introduce such a thing?
The fact that "case 1: 1" is not allowed for new switch expression (missing yield) but "case 1: method()" is allowed is really weird Why did they introduce such a thing?
Who is online
Users browsing this forum: Bing [Bot] and 10 guests