Skip to content

Instantly share code, notes, and snippets.

@arsalankhan994
Created January 1, 2022 15:46
Show Gist options
  • Save arsalankhan994/eb0a23b42ddd250410c7dc731afebba2 to your computer and use it in GitHub Desktop.
Save arsalankhan994/eb0a23b42ddd250410c7dc731afebba2 to your computer and use it in GitHub Desktop.
fun main() {
val methodInKotlin = MethodInKotlin()
methodInKotlin.methodWithoutReturnTypeAndNoParameter()
val first = methodInKotlin.methodWithReturnTypeAndNoParameter()
println("return type of methodWithReturnTypeAndNoParameter: $first")
methodInKotlin.methodWithoutReturnTypeWithParameter("Erselan Khan")
val second = methodInKotlin.methodWithReturnTypeWithParameter("Erselan Khan")
println("return type of methodWithReturnTypeWithParameter: $second")
}
class MethodInKotlin {
fun methodWithoutReturnTypeAndNoParameter() {
println("called method methodWithoutReturnTypeAndNoParameter")
}
fun methodWithReturnTypeAndNoParameter(): String {
return "Erselan Khan"
}
fun methodWithoutReturnTypeWithParameter(name: String) {
println("called method methodWithoutReturnTypeAndNoParameter, Print my name: $name")
}
fun methodWithReturnTypeWithParameter(name: String): String {
return name
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment