Last active
August 29, 2015 14:13
-
-
Save ppareit/3f85303b996091a44cb6 to your computer and use it in GitHub Desktop.
Making StringBuilder usable from Xtend
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
| package ppareit.util | |
| // Add following import to any file thats wants to use StringBuilder | |
| import static extension ppareit.util.StringBuilderUtil.* | |
| class StringBuilderUtil { | |
| /* | |
| * Make += work correctly on StringBuilder objects. | |
| */ | |
| static def <T> +=(StringBuilder builder, T t) { | |
| builder.append(t) | |
| } | |
| /* | |
| * Example usage: | |
| */ | |
| static def main(String [] args) { | |
| val msg = new StringBuilder() | |
| msg += "Some text " | |
| msg += "gets added" | |
| System.out.println(msg.toString()) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment