Last active
April 19, 2019 16:09
-
-
Save StylingAndroid/8c718d5d7c449f8b637bfb9b31b17f63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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