MainActivity : Activity(), Pikkel by PikkelDelegate() { var data by state<String>(“”) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) restoreInstanceState(savedInstanceState) } override fun onSaveInstanceState(outState: Bundle?) { super.onSaveInstanceState(outState) saveInstanceState(outState) } }
tom = new People.Builder() .name(“Tom”) .age(12) .hobby(“Baseball”) .build(); tom.hello(); これも⽴派なDSL new や .Builder()….build()等 ドメインとは無関係の記述が複雑 ()とか;とか冗⻑
StateMachine( var currentState: State, val states: Map<String, State>) class State( val name: String, val events: Map<String, Event>) class Event( val nextState: String, val action: (()-> Unit)?)
class A { operator fun invoke( arg: String){ print(“this is a with $arg”) } } val a = A() a(“foo”) // this is a with foo A()(“bar”) // this is a with bar