Dashboard sipadu mbip
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

whenEmpty.md 561B

whenEmpty()

The whenEmpty method will execute the given callback when the collection is empty:

const collection = collect([]);

collection.whenEmpty(c => c.push('Mohamed Salah'));

collection.all();

// ['Mohamed Salah']
const collection = collect(['Sadio Mané']);

collection.whenEmpty(
  c => c.push('Mohamed Salah'),
  c => c.push('Xherdan Shaqiri'),
);

collection.all();

// [
//   'Sadio Mané',
//   'Xherdan Shaqiri',
// ];

View source on GitHub