Hey all. This article states that I can only declare multiple variables of the same type inside a for loop. I was wondering whether there is any way around that, I would like to declare multiple types of variables in my for loop.
I know this sounds unkosher, and it is :D I'm trying to transform a big block of readable code into one single for loop where everything happens in the for loop except the output to console, just for the giggles of it. If anyone is interested in a piece of code ripped out of its context, here ya go:
Question
robz0rz
Hey all. This article states that I can only declare multiple variables of the same type inside a for loop. I was wondering whether there is any way around that, I would like to declare multiple types of variables in my for loop.
I know this sounds unkosher, and it is :D I'm trying to transform a big block of readable code into one single for loop where everything happens in the for loop except the output to console, just for the giggles of it. If anyone is interested in a piece of code ripped out of its context, here ya go:
for(boolean player=round%2,String tokens[]=Terminal.askString("Player "+player?"1":"2"+"> ").split("\\s+"),int x=Integer.parseInt(tokens[0]),int y=Integer.parseInt(tokens[1]); fields[!player].dropBomb(x,y); Terminal.println("Hit") ); Terminal.println("Miss");Link to comment
Share on other sites
3 answers to this question
Recommended Posts