Dashboard sipadu mbip
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

whenNotEmpty.md 622B

whenNotEmpty()

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

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

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

collection.all();

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

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

collection.all();

// [
//   'Sadio Mané',
//   'Mohamed Salah',
// ];

View source on GitHub