[enhance] use require() to set precondition
That's a suggestion by Programming Scala