Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 10. Traits > Objects with Traits

10.4. Objects with Traits

You can add a trait to an individual object when you construct it. To set up an example, we will use the Logged trait that is defined in the standard Scala library. It’s like our Logger, except that it comes with a do-nothing implementation:

trait Logged {
  def log(msg: String) { }
}


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial