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

猜你喜欢

转载自dingran.iteye.com/blog/1931562
今日推荐