hazertothepast

Meta Args proposal

Jun 15th, 2017
161
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. data class Person(val name: String, val age: Int)
  2.  
  3. fun doSomething(metaargs p: Map<String, Any?>) {
  4.     val name = p["name"] as String
  5.     val age = p["age"] as Int
  6. )
  7.  
  8. // Usage:
  9. val john = Person(name = "John Doe", age = 25)
  10. doSomething(**john)
  11.  
  12. // or as:
  13. doSomething(name = “John Doe”, age = 25)
RAW Paste Data