mercredi 25 mars 2015

Using Option[string] in a string the cleanest way in Scala?


Vote count:

0




I'm wondering if this little snippet of code:



val some = Some("string").getOrElse("")
val none = None.getOrElse("")

println(s"some $some none $none") -> some string none


Could be written cleaner? And I am mainly looking at the getOrElse part.


Can I use an Option in a String without having to use getOrElse?


Thanks for your input :)


Davey



asked 42 secs ago

Davey

180






Using Option[string] in a string the cleanest way in Scala?

Aucun commentaire:

Enregistrer un commentaire