Skip to content

anonymous /else.java

else
String timeZone;
try {
timeZone = getParam("timezone");
if (null == timeZone) {
throw new Exception();
}
} catch (final Exception e) {
return "US/Eastern";
}
return timeZone;
@edgework

Why not:

String timeZone = getParam("timezone");
return (timeZone ? timeZone : "US/Eastern");

?

@benwaffle

because timeZone isn't a boolean
this isn't C, unfortunately

@benwaffle

Best way with java 8 optional
String timeZone = getParam("timezone").orElse("US/Eastern");

@ttaylorr
String timeZone = getParam("timezone");
return timeZone == null ? "US/Eastern" : timeZone;
@edgework

oh yeah. Verbosity in a language makes it Enterprise Ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.