Tianyu Zhu
fun test(foo: List<Number>) { if (foo.containsOnly<Int>()) { val bar: List<Int> = foo } }
filterIsInstance()
MR3Y
inline fun <reified T: Number> List<Number>.containsOnly(): Boolean { contract { returns(true) implies this is List<T> } forEach { if(it !is T) return false } return true }
this is List<T>
List<T>
A modern programming language that makes developers happier.