์ฝ”๋”ฉํ…Œ์ŠคํŠธ๊ธฐ์ดˆ 3

[ Swift ] zip(_:_:)

Documentation /Swift /Swift Standard Library /Collections /zip(_:_:) zip(_:_:) func zip( _ sequence1: Sequence1, _ sequence2: Sequence2 ) -> Zip2Sequence where Sequence1 : Sequence, Sequence2 : Sequence ๋‘ ๊ฐœ์˜ sequence๋กœ ๊ตฌ์„ฑํ•œ sequence ์Œ์„ ๋งŒ๋“œ๋Š” ํ•จ์ˆ˜์ด๋‹ค. Array, String, Range์ฒ˜๋Ÿผ Sequence ํ”„๋กœํ† ์ฝœ์„ ์ฑ„ํƒํ•œ ํƒ€์ž…์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์˜จ๋‹ค. ์ฆ‰, ์ˆœ์„œ๊ฐ€ ์žˆ๋Š” ํƒ€์ž…์„ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๊ฐ€์ง„๋‹ค ํŠœํ”Œ sequence ๋ฐ˜ํ™˜ zip์„ ์‚ฌ์šฉํ•ด ๋‘ sequence๋ฅผ ํ•ฉ์น˜๋ฉด ๊ฐ ์›์†Œ๋“ค์ด ๋™์ผํ•œ ์ธ๋ฑ์Šค ์›์†Œ๋“ค๊ณผ ์ง์„ ์ง€์–ด ํŠœํ”Œ ํƒ€์ž…์˜ Z..

Swift 2023.10.08

[ Swift ] isCase | isLowercase | isUppercase

isCase ํ•ด๋‹น Character์˜ ๋Œ€์†Œ๋ฌธ์ž ๋ณ€ํ™˜์ด ๊ฐ€๋Šฅ ์—ฌ๋ถ€๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋Š” ํ”„๋กœํผํ‹ฐ์ด๋‹ค. String์ด ์•„๋‹ˆ๋ผ Character์˜ ์ธ์Šคํ„ด์Šค ํ”„๋กœํผํ‹ฐ๋ผ๋Š” ์ ์„ ์ฃผ์˜ํ•˜์ž. ๋Œ€์†Œ๋ฌธ์ž๊ฐ€ ์žˆ๋Š” ์˜์–ด๋Š” ture์ด์ง€๋งŒ ํ•œ๊ธ€, ์•„์ด์ฝ˜, ํŠน์ˆ˜๋ฌธ์ž ๋“ฑ์€ false์ด๋‹ค. let english = "a" let korean = "๊ฐ€" let icon = "๐Ÿงš๐Ÿป‍โ™€๏ธ" let half = "½" if english.first!.isCased { print(english) } // Prints "a" if korean.first!.isCased { print(korean) } if icon.first!.isCased { print(icon) } if half.first!.isCased { print(half) } isLowe..

Swift 2023.10.04

[ Swift ] print(_:separator:terminator:)

print(_:separator:terminator:) func print( _ items: Any..., separator: String = " ", terminator: String = "\n" ) ์ฃผ์–ด์ง„ ์•„์ดํ…œ์˜ ํ…์ŠคํŠธ ํ‘œํ˜„์„ ํ‘œ์ค€ ์ถœ๋ ฅํ•œ๋‹ค. items๋ฅผ ์ œ์™ธํ•œ ๋‹ค๋ฅธ ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ๊ธฐ๋ณธ๊ฐ’์ด ์„ค์ •๋˜์–ด์žˆ๊ธฐ ๋•Œ๋ฌธ์— ํ•จ์ˆ˜ ํ˜ธ์ถœ ์‹œ ๊ฐ’์„ ์ „๋‹ฌํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค. Items items์€ Any ํƒ€์ž…์œผ๋กœ, ํƒ€์ž…๊ณผ ์•„์ดํ…œ์˜ ๊ฐœ์ˆ˜์— ์ƒ๊ด€์—†์ด ํ…์ŠคํŠธ๋กœ ํ‘œํ˜„๋˜์–ด ์ถœ๋ ฅ๋œ๋‹ค. items๋Š” String(item)๊ณผ ๊ฐ™์€ ์ž‘์—…์„ ์ž๋™์œผ๋กœ ํ•ด์ฃผ๊ธฐ ๋•Œ๋ฌธ์— ํƒ€์ž… ๋ณ€ํ™˜์„ ํ•ด์ฃผ์ง€ ์•Š์•„๋„ ๋œ๋‹ค let number: Int = 120 print(number) // Prints "120" seperator separator์€ ์—ฌ๋Ÿฌ ์•„์ดํ…œ์ด ์žˆ์„..

Swift 2023.10.04
728x90