letvalue=readLine()
# 키보드 입력받은 값 공백으로 구분하기
letnumSplit=readLine()!.split(seperator:"")letnumComponent=readLine()!.components(seperatedBy:"")// import Foundation 해야 사용이 가능하다 (용량 up)
varstring=["1","2","3"]
string.map{Int($0)! }// 각 원소를 전부 Int로 매핑
array.filter{ $0 %2==0}// 조건에 맞는 수만 뽑아냄
array.reduce(0,+)// 숫자의 합이 나타남, 문자열 합치기도 가능하다.
String, SubString, Index 다루기
letsecondIndex= string.index(after: string.startIndex)letsecond=string[secondIndex]letendIndex= string.index(before: str.endIndex)// n번째 문자 index 구하는 법letindext= string.index(string.startInex, offsetBy: n -1)// subString 구하는 법letsubstring=string[start...end]// 문자 검색해서 index 찾기 "abc123".index(firstOf:"c")// 특정 character replace
string.replacingOccurences(of:"", with:"+")// print할 때, 따음표(') 쌍따음표(") 출력하기 print("이렇게 \' 써준다")// 이렇게 ' 써준다