Skip to content

L12: Delegation and Delegated Properties

In this lesson we will explore:

  • Deep Theory: First-class interface delegation (by), standard library property delegates (lazy, Delegates.observable, Delegates.vetoable), and implementing Custom Property Delegates via ReadOnlyProperty / ReadWriteProperty.
  • Under the Hood: How the compiler generates hidden synthetic fields ($$delegate) and accessor methods redirecting property calls to getValue and setValue.
  • Incremental Lab (AI Chat CLI): Building a custom property delegate to automatically persist message history to disk (history.txt) whenever state changes.