Created
November 27, 2018 11:01
-
-
Save augustovictor/b973a9cb0c15bee6ab80ced395249d0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Box<T> { | |
| private var element: T? = null | |
| fun put(e: T) { | |
| element = e | |
| } | |
| fun get(): T? = element | |
| } | |
| fun main(args: Array<String>) { | |
| val bString = Box<String>() | |
| bString.put("opa") | |
| val bInt = Box<Int>() | |
| bInt.put(10) | |
| println(bString.get()?.length) | |
| println(bInt.get()?.plus(1)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment