`
dingran
  • 浏览: 371950 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Android中TextClock中的一个abc函数

阅读更多

在TextClock中一个函数吸引了我的注意:

 

    /**
     * Returns a if not null, else return b if not null, else return c.
     */
    private static CharSequence abc(CharSequence a, CharSequence b, CharSequence c) {
        return a == null ? (b == null ? c : b) : a;
    }

 

这个函数的作用是,如果如果a不为空则返回a,如果b不为空则返回b,最后返回c。

 

很精简,abc类型的函数啊真是,作用也明显。

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics