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