How can I define an anonymous generic Scala function?

Posted by Geo on Stack Overflow See other posts from Stack Overflow or by Geo
Published on 2010-03-31T16:09:30Z Indexed on 2010/03/31 16:13 UTC
Read the original article Hit count: 295

Let's say I have this:

val myAnon:(Option[String],String):String = (a:Option[String],def:String) => {
   return a.getOrElse(def)
}

Don't mind what the function does. Is there anyway of making it generic, so I can have an Option[T]?

© Stack Overflow or respective owner

Related posts about scala

Related posts about anonymous-function