Answer the question
In order to leave comments, you need to log in
Is it possible to shorten such a structure?
class Navigator {
companion object {
private fun add(command: ICommand) {...}
private fun replace(fragment: Fragment) {...}
fun showMain() = add(object : ICommand {
override fun execute() {
replace(MainFragment.newInstance())
}
})
public static void showMain() {
add(() -> replace(MainFragment.newInstance()));
}
Answer the question
In order to leave comments, you need to log in
class Navigator {
companion object {
private inline fun add(command: () -> Unit) {}
private fun replace(fragment: Fragment) {}
fun showMain() = add { replace(MainFragment.newInstance()) }
}
}
seems to have figured it out
private var add = { command: ICommand ->App.instance.commandExecutor.add(command) }
private var replace = { fragment: Fragment -> ..... }
fun showMain() = add(object : ICommand {
override fun execute() = replace(MainFragment.newInstance())
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question