Jan 6, 2022
Thanks Mark. Yes, Scala 3 makes it very convenient to introduce type classes. The example boils down to this in Scala 3:
case class Tweet(
username: String,
content: String,
reply: Boolean,
retweet: Boolean)
given Summary[Tweet]
with extension(tweet: Tweet) def summarize: String =
import tweet._
s"$username: $content"
Then we can call .summarize directly on a Tweet instance. I'll also update the article with this information.