Created
June 16, 2019 12:23
-
-
Save automationhacks/183ceedb143a30faa476e2a61f742047 to your computer and use it in GitHub Desktop.
Moved function outside class as first class object and use of default 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
package _03_functions | |
fun getFirstWord(word: String, separator: String = " "): String { | |
return word.split(separator)[0] | |
} | |
fun main() { | |
val first = 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