```UserModel.Creator( _, foo, bar, cat, moo, _ -&g...
# getting-started
r
Copy code
UserModel.Creator(
_, foo, bar, cat, moo, _ -> User(foo, bar, cat, moo)
)
works fine, but
Copy code
UserModel.Creator(
_, foo, bar, cat, moo, _ -> {
Log.d("")
User(foo, bar, cat, moo)
}
)
doesn’t work.
m
i believe that happens because when you add the closure brackets the compiler detects it as a function returning Unit
r
well, from the error log I posted earlier, it seems to the the result is
((Long, String, String, String, String, String?) -> () -> User)
r
What if you specify
UserModel.Creator<() -> User>(...)
?
r
Unfortunately, that doesn’t work since the expected type from the root factory object is
User
m
Needs to be
Copy code
UserModel.Creator( {
_, foo, bar, cat, moo, _ ->
Log.d("")
User(foo, bar, cat, moo)
}
)
👍 2
or
Copy code
UserModel.Creator {
_, foo, bar, cat, moo, _ ->
Log.d("")
User(foo, bar, cat, moo)
}
👍 1
r
thanks, I guess I don’t fully understand the consequences of wrapping code in a closure
r
Ah, I see. In that case do what @mwerschy says. (EDIT: you already did 🙂)