edwardwongtl
04/11/2018, 3:48 AMfun doSth(action: Mode.() -> Unit)?
But Mode contains only functions, no properties.
Although it is completely fine to create instance of Mode and pass it to action(mode), it just doesn't quite make sense for me to create such a instance.gildor
04/11/2018, 4:51 AMedwardwongtl
04/11/2018, 5:06 AMadd, minus inside fun doSthedwardwongtl
04/11/2018, 5:08 AMfun doSth(action: Mode.() -> Unit) { ... }
doSth {
add() // OK
minus() // OK
multiple() // Not ok
}gildor
04/11/2018, 5:41 AMgildor
04/11/2018, 5:41 AMedwardwongtl
04/11/2018, 5:41 AMgildor
04/11/2018, 5:42 AMedwardwongtl
04/11/2018, 5:42 AMfun doSth(...) {
action(mode) // Don't want to pass in mode
}edwardwongtl
04/11/2018, 5:43 AMMode consist of pure functions, I'm just using it for function grouping purpose in this case.edwardwongtl
04/11/2018, 5:44 AMinterface Mode instead of class Mode?gildor
04/11/2018, 5:54 AMclass/interface Mode {
fun add()
fun minus()
}
class MultipleMode: Mode {
fun multiple()
}edwardwongtl
04/11/2018, 5:56 AM