I looked through the website to find something in scala that might resemble or work like an F # class, but it doesn't matter where I look. I can find nothing but the case class, which seems a bit like it ... but how do they differ from each other?
eg:
type Shape = | Circle of double | Square of double let area = function | Circle radius -> 3.1415 * radius * radius | Square length -> length * length let circle = Circle(15.0) printfn "The circle area is %A" (area circle)
- is the above code basically of the case class or do I need to do something else to get the same functionality?
source share