Created
July 23, 2013 14:18
-
-
Save evanchooly/6062704 to your computer and use it in GitHub Desktop.
optional parameters
This file contains 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 void something(X x, Y y) { | |
something(x, y, someDefaultValue); | |
} | |
public void something(X x, Y y, SomeObject object) { | |
// do work | |
} | |
// vs | |
public void something(X x, Y y, SomeObject... objects) { | |
SomeObject object = object.length == 0 ? someDefaultValue : object[0]; | |
// do work | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment