gpt4 book ai didi

java - 避免空检查

转载 作者:行者123 更新时间:2023-11-30 07:41:14 24 4
gpt4 key购买 nike

我想避免使用三元表达式进行 null 检查,即 return x == null ? null : return x.y; 所以我想返回另一个可能为 null 的对象的复合对象 - 在这种情况下我只想返回 null。我正在寻找一些实用方法(Guava mby?),它比带有空检查的三元表达式更短。

最佳答案

关于java - 避免空检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34674607/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com