Created
November 14, 2015 02:10
-
-
Save itrion/78415f218234fec38af2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fun main(args: Array<String>) { | |
println(helloTo("Johan")) | |
println(sumOf(1)) | |
println(sumOf(1, 2)) | |
println(sumOf(lhs = 1, rhs = 2)) | |
println(sumOf(1, 2, 3, 4, 5)) | |
val customer = Customer("Customer", "[email protected]") | |
// customer.name = "not allowed, name is val" | |
customer.email = "[email protected]" | |
println(customer.name) | |
println(customer.email) | |
val employee = Employee("employee", "Developer") | |
println(employee) | |
fun Employee.sayHelloTo(name: String) = println("Hello $name") | |
employee.sayHelloTo(customer.name) | |
} | |
data class Employee(val name: String, val job: String) | |
class Customer(val name: String, var email: String) | |
fun helloTo(name: String): String { | |
return "Hello $name" | |
} | |
fun sumOf(lhs: Int, rhs: Int): Int { | |
return lhs + rhs | |
} | |
fun sumOf(vararg numbers: Int): Int { | |
return numbers.sum() | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment