Working with traits

As we saw, case classes significantly simplify handling of new nested data structures that we want to construct. The case class definition is probably the most convincing reason to move from Java (and SQL) to Scala. Now, what about the methods? How do we quickly add methods to a class without expensive recompilation? Scala allows you to do this transparently with traits!

A fundamental feature of functional programming is that functions are a first class citizen on par with objects. In the previous section, we defined the two EpochSeconds functions that transform the ISO8601 format to epoch time in seconds. We also suggested the splitSession function that provides a multi-session view for a given IP. How do we associate this ...

Get Mastering Scala Machine Learning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.