You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element should be included in the returned array.
filter 함수의 매개변수로 전달되는 함수의 반환 타입은 Bool 타입이다. 즉, 새로운 컨테이너에 포함될 항목이라면 true를, 포함하지 않는다면 false를 반환 해준다.
Return Value
An array of the elements that isIncluded allowed.
Details
letcast=["Vivien","Marlon","Kim","Karl"]letshortNames= cast.filter{ $0.count <5}print(shortNames)
// Prints "["Kim", "Karl"]"