Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. // the A in front of the file name is just to keep this on top in the gist lol
  2. inline fun <reified T> testReified(obj: T) {
  3. // None of these are possible in Java because of Type Erasure
  4. if (obj is Int) {
  5. println(5 + obj)
  6. } else {
  7. println(obj)
  8. }
  9.  
  10. val x = 5
  11. if (x is T) {
  12. println("5 is type T")
  13. }
  14. }
  15.  
  16. fun main(args: Array<String>) {
  17. testReified(5)
  18. testReified("5")
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement