is it possible to have a custom property delegate ...
# announcements
is it possible to have a custom property delegate that can provide a nullable value to a nullable property and a non-nullable value to a non-nullable field? aka:
Copy code
class Foo {
    val one : String by someProperty()
    val two : String? by someProperty()
….and if so, what would be the signature of 
operator fun getValue(…)
? I guess I could do 
val two : String? by someOptionalProperty()
 to make the type signature easier, but that feels like I’m giving up, y’know?
it's possible (a bunch of delegates from stdlib allows this, e.g.
) just leave it as T and perform unchecked cast if necessary (like
return null as T
🤦🏾‍♂️ that makes perfect sense, thank you!
there’s also the option of using
if you want to return different implementations for nullable vs non-nullable properties (Gradle’s kotlin-dsl does this for project properties, for example)
👍🏾 1