Skip to content

Instantly share code, notes, and snippets.

@rlespinasse
Last active August 29, 2015 14:26
Show Gist options
  • Save rlespinasse/65e470fe61b33c4fbfd4 to your computer and use it in GitHub Desktop.
Save rlespinasse/65e470fe61b33c4fbfd4 to your computer and use it in GitHub Desktop.
substring.golo
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