ITeye博客

Android中TextClock中的一个abc函数

dingran · 2013-08-27 14:27 · 移动开发 · Markdown

在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类型的函数啊真是,作用也明显。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。