Java 7 New Features
addhen.org
addhen.org
Ruby, Python, C#, Objective-C, Javascript, C++ 11
...
PHP
If you happen to find yourself being the personification of a programming language, and if you discover that PHP is a more advanced language than yourself then you have my permission to spend a night drinking heavily before hanging yourself from a lamp cord tied to a rafter in the garage.
But I forgot this was HN: the place where people are allergic to homoiconicity ; )
> There have been countless times when I wished I could
> have just used a String in a switch statement. When I
> hit this block when coding, I’m forced by Java to refactor
> my code to use a primitive datatype in my switch statement
I tend to use an enum instead, as it keeps the meaning clearer. For his example: private static enum StringFields { ADDO_QUAYE, BOATENG_NICOLAS, DEFAULT }
try {
field = StringFields.valueOf(fullName.replace(' ', '_').toUpperCase());
} catch(IllegalArgumentException e) {
field = StringFields.valueOf("DEFAULT");
}
switch (field) {
case ADDO_QUAYE:
System.out.println("He is the SRC president");
break;
case BOATENG_NICOLAS:
System.out.println("He is the SU president");
break;
case default:
System.out.println("He is no body!");
break;
}I don't see this as an improvement. A good practice is to use Enums for case/switch. Using String is harder to maintain.