I am new to scala but basically found my way ...
Here I ask for a recommended / best practice / idiomatic way to implement this:
- internally, MyClass uses a state type that is implemented using a sealed case class hierarchy
- but in the API, only some logical predicate should be opened, which is implemented by matching with the (internal) state.
My implementation is currently running line by line ...
def isSane: Boolean = state match {
case Ok(_,'valid) => true
case _ => false
}
But this decision seems awkward to me, as if expressing something in three lines of code, which has only information content, standing on one line of code. In fact, I would like to write:
def isSane: boolean = state matches Ok(_, 'valid)
/, scala, , , . , ?