Search
 
SCRIPT & CODE EXAMPLE
 

SCALA

sum type scala

sum type is generally (2.x) encoded as a:

sealed trait ProductType
object ProductType {
     case object Element1 extends ProductType
     case class Element2(field1: Type1) extends ProductType
     ...
     case class ElementN(field1: Type1) extends ProductType
}

- "sealed" -> protect against wild extension
- case in object for code organisation
Comment

PREVIOUS NEXT
Code Example
Scala :: how to make anonymous function in scala 
Scala :: scala merge list of strings 
Scala :: how to get absolute value in scala 
Scala :: scala learn 
Scala :: scala list of options to option of list 
Actionscript :: mv ~/.npmrc ~/.npmrc.old npm prefix -g 
Actionscript :: mass transit logging to seq 
Excel :: excel use offset in conditional formatting 
Excel :: excel conditionally highlight multiple columns based on one column 
Excel :: excel and function 
Perl :: perl post condition 
Perl :: unique in perl 
Perl :: Perl - Common Conditional Statements 
Pascal :: pascal sleep 
Pascal :: pascal cheat sheett 
Powershell :: powershell scriptblock return variable 
Clojure :: clojure read file line by line 
Lisp :: Doom emacs pdf-tools 
Assembly :: custom color bootstrap buttonm 
Assembly :: node js vulnerabilities 
Assembly :: links in markdown 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: jquery 2 decimal places 
Javascript :: how to insatll react-router-dom 
Javascript :: jquery delay 1 second 
Javascript :: chrome design mode console 
Javascript :: f.select on change jquery 
Javascript :: execute after one second javascript 
Javascript :: electron hide menu bar 
Javascript :: javacsript update text in span 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =