Passing Optional.absent() values to methods concisely

后端 未结 3 1233
不思量自难忘°
不思量自难忘° 2021-02-18 22:31

One problem with using Guava\'s Optional type as arguments of methods is that you can\'t simply write

// method declaration
public void foo(Optional         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-18 22:44

    So, this is the right way to do this. If not for anything else, let me at least show it here for my own future reference, for everyone who doesn't read questions, like myself :) Thanks to ColinD (and Alexey).

    foo(Optional.absent())
    

提交回复
热议问题