Skip to content

Instantly share code, notes, and snippets.

@itrion
Created November 14, 2015 02:10
Show Gist options
  • Save itrion/78415f218234fec38af2 to your computer and use it in GitHub Desktop.
Save itrion/78415f218234fec38af2 to your computer and use it in GitHub Desktop.
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