Skip to content

Instantly share code, notes, and snippets.

View balhoff's full-sized avatar

Jim Balhoff balhoff

View GitHub Profile
@chaotic3quilibrium
chaotic3quilibrium / Effective Scala Case Class Patterns.md
Last active May 1, 2024 15:49
Article: Effective Scala Case Class Patterns - The guide I wished I had read years ago when starting my Scala journey

Effective Scala Case Class Patterns

Version: 2022.03.02

Available As

@vlfig
vlfig / TestCaseClassInterning.scala
Created September 20, 2012 17:27
Traits to easily make classes intern their instances assuring no duplicates exist at runtime. Don't forget to check your equals and hashCode.
import scala.collection.mutable.WeakHashMap
/**
* Utility traits for classes whose companion objects are to
* intern their instances, never creating repeated objects.
*
* Instances are cached based on their immutable
* arguments, as provided to companion object's {{apply()}}.
*/