更新时间:2023-11-11 12:09:16
it
始终引用最内部的lambda参数,要访问外部参数,则必须命名它们.例如:
it
always refers to the innermost lambda's parameter, to access outer ones, you have to name them. For example:
list1.filter { a -> list2.none { b -> a.weekday == b.weekday && a.time == b.time} }
(您可以将内部的内容保留为it
,但我认为也可以更好一点).
(You could leave the inner one as it
, but it's a bit nicer if you name that too, in my opinion.)
编辑:@ mfulton26链接了下面的相关文档,请参阅该文档以获取更多详细信息.
@mfulton26 linked the relevant documentation below, see that for more details.