What is `R` supposed to be set by default on this ...
# getting-started
a
What is
R
supposed to be set by default on this snippet?
c
Yeah, the documentation is a bit confusing for delegates.
thisRef
will refer to the object that contains the delegate, which would be an instance of class
D
in your snippet. Delegates can also be used on local or top-level properties, at which point it doesn't have a "containing object" to refer to and will be the
Nothing
type
🙏 2
a
That’s right! I just figured it out. What’s not clear to me is how the semantics EffectiveDate() works without doing EffectiveDate<D>() @Casey Brooks
c
Compiler magic basically 😉. The
R
type will always refer to the type of class it's contained in (or
Nothing
). So the compiler sees that you're calling
EffectiveDate()
and assigning it to a member property within class
D
, so that becomes the
R
type
😉 1