Is there any way to check if generic parameter is ...
# reflect
v
Is there any way to check if generic parameter is nullable? Basically, I want to be able to write something like:
Copy code
public inline fun <reified V : View?> View.find(id: Int): V {
  val result = findViewById(id)

  if (result == null && !V::class.isNullable) {
    throw IllegalArgumentException("Unable to find view ${view.resources.getResourceName(id)}")
  }

  return result as V
}