Join Slack
Powered by
I'm trying to reduce boilerplate when creating an ...
# getting-started
r
Rob Elliot
05/16/2024, 8:59 AM
I'm trying to reduce boilerplate when creating an object as a subtype of an abstract class, with arbitrary fields, and can't work it out 🧵
Rob Elliot
05/16/2024, 9:00 AM
My current code looks like this:
Untitled.kt
Rob Elliot
05/16/2024, 9:02 AM
I feel I should be able to reduce it to something like this, using extension methods and a `PropertyDelegateProvider`:
Untitled.kt
Rob Elliot
05/16/2024, 9:03 AM
But I'm not sure it's possible to declare the fields of the subclass like this!
Rob Elliot
05/16/2024, 1:36 PM
Using the code
here
I can do this, which is quite close to what I want. I'm pleasantly surprised that
flat_subjects.subject_id
compiles! I expected it would have lost the anonymous inner object's fields by returning it from a function.
Untitled
Open in Slack
Previous
Next