Skip to content

Instantly share code, notes, and snippets.

@rinotc
Created August 1, 2021 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rinotc/bcd386d9c5db7d09ba728c799c447669 to your computer and use it in GitHub Desktop.
Save rinotc/bcd386d9c5db7d09ba728c799c447669 to your computer and use it in GitHub Desktop.
Scala で case class を使った場合の、デフォルトパラメータが必要な時のBuilder Patternサンプル
case class NutritionFacts(
servingSize: Int,
servings: Int,
calories: Int = 0,
fat: Int = 0,
sodium: Int = 0,
carbohydrate: Int = 0
)
val nf = NutritionFacts(1, 1, fat = 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment