Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fun main() {
val classOne = ClassOne()
val color1 = classOne.obtainColor(context, R.color.my_color)
val classTwo = ClassTwo()
classTwo.obtainColor(R.color.my_color, context.resources::getColor)
}
class ClassOne() {
fun obtainColor(context: Context, colorRes: Int) = context.resources.getColor(colorRes)
}
class ClassTwo {
fun obtainColor(colorRes: Int, colorLookup: (Int) -> Int) = colorLookup(colorRes)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment