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
sayMyFullName(lastName = "Mgbemena", middleName = "Nnamdi", firstName = "Chike") // will still compile
package com.chikekotlin.projectx
class MyClass
import com.chikekotlin.projectx.*
import com.chikekotlin.projectx.saySomething
import com.chikekotlin.projecty.saySomething as projectYSaySomething
fun main(args: Array<String>) {
projectYSaySomething()
}
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, pi: Double = Math.PI): Double = (2 * pi) * radius
print(calCircumference(24.0)) // used default value for PI and prints 150.79644737231007
print(calCircumference(24.0, 3.14)) // passed value for PI and prints 150.72