take a look at this simple extension function i have infix:
infix fun View.isValidColor(hexColor: String?): Boolean {
var isValid = true
return hexColor?.let {
try {
Color.parseColor(it)
} catch (e: Throwable) {
isValid = false
}
isValid
} ?: false
}
//notice how i have infix the extension meaning brackets are not needed, hopefully making it easier to read.
Now lets see the usage and what i have tried:
its not being infix and it follows the rule for infix that:
- Must be member functions or extension functions.
- They must have a single parameter.
- The parameter must not accept a variable number of arguments and must have no default value.
what am i doing wrong ?
UPDATE:
I ALSO tried this but its working by explicitly calling the referring class:
since now im using the explicit object why did it fail ? ivLogo is a ImageView synthetic from kotlin.