Skip to content

Instantly share code, notes, and snippets.

Created July 16, 2014 20:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/747f7cf6a1e4039ddbf3 to your computer and use it in GitHub Desktop.
Save anonymous/747f7cf6a1e4039ddbf3 to your computer and use it in GitHub Desktop.
else
String timeZone;
try {
timeZone = getParam("timezone");
if (null == timeZone) {
throw new Exception();
}
} catch (final Exception e) {
return "US/Eastern";
}
return timeZone;
@edgework
Copy link

Why not:

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

?

@benwaffle
Copy link

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

@benwaffle
Copy link

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

@ttaylorr
Copy link

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

@edgework
Copy link

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