Joshy Josh
07/24/2020, 10:17 PMfun <T> screen(init: T.() -> Unit): T = init as T
Then eventually extend it have bounds, but for now. I keep getting a casting error. I’m assuming because it’s not invoking init, but I can’t seem to figure that part out.Joshy Josh
07/24/2020, 10:20 PMfun class(init: MainView.() -> Unit) = screen(init)
Joshy Josh
07/24/2020, 10:48 PMfun <T> screen(obj: T, init: T.() -> Unit): T {
obj.init()
return obj
}
then invoking with
fun(view: MainView.()-> Unit) = screen(MainView(), view)
simply because I’m sending in the object. Is there a better approach so I don’t have to explicitly send in the MainView()
to the generic builder?Jakub Pi
07/25/2020, 3:11 AMJakub Pi
07/25/2020, 3:14 AMscreen { /* code here */ }
or screen(MainView()) {/* code here */ }
Jakub Pi
07/25/2020, 3:14 AMJoshy Josh
07/27/2020, 3:10 PM