[swift] 32. 고차함수 compactMap

RudinP·2023년 10월 3일
0

Study

목록 보기
50/227

compactMap

  • 대상이 nil인 경우 반환 X
  • unwrapping까지 해줌
let strNumbers : [String?] = ["1", "2", "3", nil]
let numbers = strNumbers.compactMap{item in 
	return Int(item)}
profile
곰을 좋아합니다. <a href = "https://github.com/RudinP">github</a>

0개의 댓글