Swift. 옵셔널
옵셔널 옵셔널이란? 값이 있을수도 있고, 없을 수도 있는 것입니다. 스위프트의 키워드 Safe, Fast, Interactive 중에 가장 중요하게 생각하는 것이 'Safe' 입니다. 옵셔널은 Safe를 가장 잘 대변할 수 있는것입니다. Int: 주황색 공간 안에 값이 무조건 있다는 것을 언어적으로 보장할게. Int?: 주황색 공간 안에 값이 있을 수도 있고, 없을 수도 있다. 값이 있으면 보호막 안에 값을 넣어 놓고, 없으면 보호막만 넣어 놓을게. Objective-C 에서는 파라미터등의 문서를 보면 'This value must not be nil' 이런 문구가 설명되어 있었다. 그래서 다른 프로그래머와 일 할 때 그 값이 nil인지 아닌지 하나하나 체크해야 했고, 심지어 자기 자신도(!!!) 이 값..
2019. 4. 18. 13:14