Skip to content

Instantly share code, notes, and snippets.

@augustovictor
Created November 27, 2018 11:01
Show Gist options
  • Select an option

  • Save augustovictor/b973a9cb0c15bee6ab80ced395249d0f to your computer and use it in GitHub Desktop.

Select an option

Save augustovictor/b973a9cb0c15bee6ab80ced395249d0f to your computer and use it in GitHub Desktop.
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