Kotlin functions
fun hello() {
println("hello world")
}
fun hello(name: String, age: Int) {
println("Hello, $name!")
}
fun hello(name: String = "World") {
println("Hello,$name")
}
fun hasItems(): Boolean {
return true
}
fun cube(x: Double): Double = x * x * x
fun sum(vararg x: Int) {}
fun main1(args: Array<String>) {}
fun main(args: Array<String>) {
openFile("file.txt", readOnly = true)
}
fun openFile(fileName: String, readOnly: Boolean): File {
}
fun createFile(fileName: String, appendDate: Boolean = false, executable: Boolean = false): File {}
fun init() {
val module = createList<String>("net")
val moduleInferred = createList("net")
}
fun <T> createList(item: T): List<T> {}
fun createBook(): Book {
return Book("title_01", "author_01")
}
data class Book(val title: String, val author: String) {
}