Skip to content

Instantly share code, notes, and snippets.

View sajjadyousefnia's full-sized avatar
🤒
Out sick

Sajjad Yousefnia sajjadyousefnia

🤒
Out sick
View GitHub Profile
fun hello(name: String): String {
return "Hello $name"
}
val message = hello("Chike")
print(message) // will print "Hello Chike"
fun hello(name: String): Unit {
print("Hello $name")
}
hello("Chike") // will print "Hello Chike"
public object Unit {
override fun toString() = "kotlin.Unit"
}
fun hello(name: String) { // will still compile
print("Hello $name")
}
fun calCircumference(radius: Double): Double {
return (2 * Math.PI) * radius
}
fun calCircumference(radius: Double) = (2 * Math.PI) * radius
fun calCircumference(radius: Double): Double = (2 * Math.PI) * radius
fun sayMyFullName(firstName: String, lastName: String, middleName: String): Unit {
print("My full name is $firstName $middleName $lastName");
}
sayMyFullName("Chike", "Nnamdi", "Mgbemena")
sayMyFullName(firstName = "Chike", middleName = "Nnamdi", lastName = "Mgbemena")