Skip to content

Instantly share code, notes, and snippets.

@jacksonfdam
Created July 24, 2018 10:23
Show Gist options
  • Save jacksonfdam/d777158760867c69d736aa76b307d028 to your computer and use it in GitHub Desktop.
Save jacksonfdam/d777158760867c69d736aa76b307d028 to your computer and use it in GitHub Desktop.
/**
* We declare a package-level function main which returns Unit and takes
* an Array of strings as a parameter. Note that semicolons are optional.
*/
fun main(args: Array<String>) {
val funcaoDeSucesso = { nome:String ->
println(nome)
}
val funcaoDeFalha = { ->
println("Nao encontrado")
}
buscaNome(funcaoDeSucesso,funcaoDeFalha )
}
fun buscaNome(sucesso: (String)->Unit,falha:()->Unit){
if(true){
sucesso("Maria")
} else {
falha()
}
}
@jacksonfdam
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment