[swift] 32. 고차함수 compactMap

RudinP·2023년 10월 3일
0

Study

목록 보기
50/380

compactMap

  • 대상이 nil인 경우 반환 X
  • unwrapping까지 해줌
let strNumbers : [String?] = ["1", "2", "3", nil]
let numbers = strNumbers.compactMap{item in 
	return Int(item)}
profile
iOS 개발자가 되기 위한 스터디룸/스터디의 레퍼런스는 모두 kxcoding

0개의 댓글