Last active
March 9, 2017 16:13
-
-
Save eckelon/e01998b34b73b9a9f03758f6aaa2faa8 to your computer and use it in GitHub Desktop.
silly way for avoiding the use of massive ternary operators in Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> T coalesce(T object) { | |
return object == null ? null : object; | |
} | |
public static <T> T coalesce(T find, T replace) { | |
return find == null ? replace : find; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment