Accessing scala.None from Java

前端 未结 6 1985
南笙
南笙 2020-12-04 01:14

How can you access scala.None from Java?

The last line causes the compiler to die with \"type scala.None does not take parameters\".

imp         


        
6条回答
  •  失恋的感觉
    2020-12-04 02:05

    This might work:

    final scala.Option x = scala.Option.apply(null);
    

    def apply [A] (x: A): Option[A]
    An Option factory which creates Some(x) if the argument is not null, and None if it is null.

提交回复
热议问题