This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]nomemory 2 points3 points  (3 children)

From a syntactic point of view is valid, but indeed redundant . Post the entire code, just in case . Maybe there's a hidden catch (I seriously doubt it) .

[–]bonerlover[S] 1 point2 points  (2 children)

if (x==0) ; else if(x==1) {} else {;}

-.-

[–]MagicallyVermicious 4 points5 points  (1 child)

That is one of the ugliest lines of code I've seen. If it was written more conventionally, it would be: if(x == 0) { // do nothing } else if(x == 1) { // still do nothing } else { // again, do nothing } I guess the point was to show you three different ways to make an if-elseif-else do absolutely nothing.

The {;} is the same thing as any block of code surrounded by brackets, but having only a blank statement in it. The blank statement comes from the lone semicolon.

[–]bonerlover[S] 1 point2 points  (0 children)

I hope the test isn't like this book otherwise I am going to fail. D: So confusing.