toPropertyGetter
Converts a static value into a PropertyGetter that always returns the same value. Useful for creating property accessors for constant or computed values.
Return
a PropertyGetter that always returns the static value
Example usage:
val staticGetter = "constant".toPropertyGetter<MyClass, String>()
val value = staticGetter.get(anyInstance) // always returns "constant"Content copied to clipboard
Parameters
T
the type of the target object (not used in static getters)
V
the type of the property value
Converts a Kotlin read-only property into a PropertyGetter. The resulting getter will access the property value from the target object.
Return
a PropertyGetter that accesses the property value
Example usage:
val propertyGetter = MyClass::name.toPropertyGetter()
val instance = MyClass("John")
val name = propertyGetter.get(instance) // returns "John"Content copied to clipboard
Parameters
T
the type of the target object
V
the type of the property value