SHARE
TWEET

Meta Args proposal

hazertothepast Jun 15th, 2017 (edited) 138 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top