我的猫模型有这个:
var id: Int?
如果我有一只猫,我如何获得所有ID为7的猫?我假设我应该使用filter方法:
let filteredCats = cats.filter(???)
答案 0 :(得分:0)
除非您没有其他要求,否则它应该一直很简单。
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Fatal error: Out of memory (allocated 57671680) (tried to allocate 2110325 bytes) in phar:///cygdrive/c/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Util/RemoteFilesystem.php on line 462
要跳过可选值,可以使用cats.filter { $0.id == 7 }
例如
compactMap