Skip to content

Instantly share code, notes, and snippets.

@automationhacks
Created June 16, 2019 12:21
Show Gist options
  • Save automationhacks/5180077b86ca19d61b0bc68550608e42 to your computer and use it in GitHub Desktop.
Save automationhacks/5180077b86ca19d61b0bc68550608e42 to your computer and use it in GitHub Desktop.
Initial Example of show use of functions and available features
package _03_functions
class StringUtils {
fun getFirstWord(word: String, separator: String): String {
return word.split(separator)[0]
}
fun getFirstWord(word: String) = getFirstWord(word, " ")
}
fun main(args: Array<String>) {
val first = StringUtils().getFirstWord("Jane Doe")
println("First word: $first")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment