How To Transform Nil To None Scala

[Solved] How To Transform Nil To None Scala | Scala - Code Explorer | yomemimo.com
Question : how to transform Nil to None scala

Answered by : perfect-panda-pj0fe2lt06m9

Nil is an empty Sequence and None is an empty Option. So use .headOption on your Nil variable
val myVal = Nil
println(myVal.headOption)

Source : | Last Update : Fri, 13 May 22

Answers related to how to transform Nil to None scala

Code Explorer Popular Question For Scala