Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // the A in front of the file name is just to keep this on top in the gist lol
- inline fun <reified T> testReified(obj: T) {
- // None of these are possible in Java because of Type Erasure
- if (obj is Int) {
- println(5 + obj)
- } else {
- println(obj)
- }
- val x = 5
- if (x is T) {
- println("5 is type T")
- }
- }
- fun main(args: Array<String>) {
- testReified(5)
- testReified("5")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement