Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //show type is erased in runtime
- // show reified
- fun <T> checkTypeAtRuntime(item: Any){
- println("${item is T}")
- }
- fun main(){
- val names: MutableList<String> = mutableListOf("John", "Sarah", "Mark")
- val ages: MutableList<Int> = mutableListOf(1,2,3)
- checkTypeAtRuntime<String>("John")
- checkTypeAtRuntime<Int>("Sarah")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement