跳到正文
本页尚未翻译成中文,以下为英文原文。 查看英文版

coalesce Function ​

coalesce takes any number of arguments and returns the first one that isn't null or an empty string.

Examples ​

shellsession
> coalesce("a", "b")
a
> coalesce("", "b")
b
> coalesce(1,2)
1

To perform the coalesce operation with a list of strings, use the ... symbol to expand the list as arguments:

shellsession
> coalesce(["", "b"]...)
b
  • coalescelist performs a similar operation with list arguments rather than individual arguments.

基于 MPL-2.0 许可证发布。