Last active
August 29, 2015 14:26
-
-
Save rlespinasse/65e470fe61b33c4fbfd4 to your computer and use it in GitHub Desktop.
substring.golo
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
module substring | |
augment java.lang.String { | |
function substring = |this, separator| { | |
return this: substring(0, this: indexOf(separator) + separator: length()) | |
} | |
} | |
function main = |args| { | |
println("abcdefgh": substring(0, 5)) // abcde | |
println("abcdefgh": substring("de")) // abcde | |
} | |
// run `golo golo --files substring.golo` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment