Skip to content

Conversation

@giancosta86
Copy link
Contributor

Introducing Java 7's switch on strings only partially solves the problem - but it definitely seems to foster readability.
Such a language construct consequently demanded a change to Gradle's build script.

@arialdomartini
Copy link
Contributor

While the switch statement, in this case, is much clearer than the equivalent original if-else if-else (particularly because it makes much clearer the fact that there is a default case), it doesn't seem to me that it removes the conditional paths, does it?

arialdomartini added a commit that referenced this pull request Jul 21, 2014
Introducing string-based switch à la Java 7
@arialdomartini arialdomartini merged commit 4586cfa into code4nothing:master Jul 21, 2014
@giancosta86
Copy link
Contributor Author

Another advantage of the switch statement is that we employ the tested variable just once, and in a very clear point! :) There are far fewer chances of error!

@arialdomartini arialdomartini changed the title Introducing string-based switch à la Java 7 Proposal #1 - Introducing string-based switch à la Java 7 Jul 22, 2014
@arialdomartini arialdomartini changed the title Proposal #1 - Introducing string-based switch à la Java 7 Solution #1 - Introducing string-based switch à la Java 7 Jul 23, 2014
arialdomartini added a commit that referenced this pull request Jul 25, 2014
Quiz #3 - Smell of Null Objects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants