Skip to content

Instantly share code, notes, and snippets.

@tmaxxdd
Last active May 30, 2018 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmaxxdd/5444d93a4960ff85604c803687acbcc8 to your computer and use it in GitHub Desktop.
Save tmaxxdd/5444d93a4960ff85604c803687acbcc8 to your computer and use it in GitHub Desktop.
class GetTopics {
// getter method
operator fun getValue(thisRef: Any?, property: KProperty<*>): Array<Topic> {
//Here we can change implementation
return Array(20, { Topic("Some topic", "Some description")} )
}
}
class MainActivity : AppCompatActivity() {
val topics: Array<Topic> by GetTopics()//delegated properties
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment