This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun executeOperation(crossinline operationTwo: () -> Unit) { | |
operationOne { | |
operationTwo() | |
} | |
} | |
@PublishedAPI | |
internal fun operationOne(block: () -> Unit) { | |
block() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Control interface | |
interface ClientFlow { | |
fun executeFlow() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Interface de controle | |
interface ClientFlow { | |
fun executeFlow() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun executarOperacao(crossinline operacaoDois: () -> Unit) { | |
operacaoUm { | |
operacaoDois() | |
} | |
} | |
@PublishedApi | |
internal fun operacaoUm(bloco: () -> Unit) { | |
bloco() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final void main() { | |
// Função de adquirir métodos | |
Method[] methods = String.class.getMethods(); | |
// Validação da String na lista | |
if (element instanceof String) { | |
// Atribuições | |
} | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
println(filtrarString<String>()) | |
println(adquirirMetodos<String>()) | |
} | |
inline fun <reified T : Any> adquirirMetodos(): List<String> { | |
return T::class.java.methods.map { it.toString() } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
println(filtrarString(String::class.java)) | |
println(adquirirMetodos(String::class.java)) | |
} | |
fun <T : Any> adquirirMetodos(clazz: Class<T>): List<String> { | |
return clazz::class.java.methods.map { it.toString() } | |
} | |
fun <T : Any> filtrarString(clazz: Class<T>): T? { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val descricao = "Inline te dando poderes mágicos" | |
executarOperacao { | |
print(descricao) | |
return // Retorno não permitido | |
} | |
} | |
inline fun executarOperacao(crossinline operacaoDois: () -> Unit) { | |
operacaoUm { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val descricao = "Inline te dando poderes mágicos" | |
val descricaoEmEscopoPrincipal = "Inline no escopo principal" | |
executarOperacao({ | |
print(descricao) | |
return // Retorno permitido | |
}, { | |
print(descricaoEmEscopoPrincipal) | |
return // Retorno não permitido |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final void main() { | |
final String descricao = "Inline te dando poderes mágicos"; | |
executarOperacao(new Function() { | |
@Override | |
public void invoke() { | |
System.out.print(descricao); | |
} | |
} | |
} |
NewerOlder