Scala Some v. Option

前端 未结 4 2066
甜味超标
甜味超标 2021-02-03 20:14

What\'s the difference between Some and Option?

scala> Some(true)
res2: Some[Boolean] = Some(true)

scala> val x: Option[Boolean]         


        
4条回答
  •  無奈伤痛
    2021-02-03 20:49

    In short

               Option
                /   \
               /     \
              /       \
            Some     None
    

    Option is container base which can be empty or full

    While Some(x) represent full with 'x' being present in the container, None represents empty.

提交回复
热议问题