Often my methods have a parameter Listthat is optional. When I get a list of elements, I do something with them, otherwise this parameter is ignored. Here is a trivial example.
scala> def convertToUpper(s: String, appenders: List[String] = List()) {
(s.toUpperCase :: appenders).mkString(" ")
}
scala> convertToUpper("cory", List("asks", "questions"))
CORY asks questions
But sometimes I wonder if this contract supports waiting for a parameter appenderswhen it really is optional. On the other hand, creating appendersa Option[List]adds complexity.
Is it a bad practice to avoid using Optionwhen the parameter is Listand can I just check the void instead None?
source
share