In this style of delegation we can see the "aliasFor" [1] before the method, which makes it more "stand out",
and it'll be kept in the docs - whereas just the in-body delegation hides this information.
Also notice that while the delegated[Int] is a bit verbose, you cannot get it wrong.
If you would type delegated[String] where the ask method clearly returnes a String here you would get a type error like this one:
[error] found : Int
[error] required: String
[error] def ?(name: String) = delegated[String]
Annotation used in the annotation style method delegation. See example bellow:
In this style of delegation we can see the "aliasFor" [1] before the method, which makes it more "stand out", and it'll be kept in the docs - whereas just the in-body delegation hides this information.
Also notice that while the delegated[Int] is a bit verbose, you cannot get it wrong. If you would type delegated[String] where the ask method clearly returnes a String here you would get a type error like this one: