๋ชฉ๋กdiscardableResult (1)

suvera-dev ๐Ÿฅฆ

Swift ) @discardableResult ๋ž€?

์˜ค๋Š˜์€ @discardableResult ๋ผ๋Š” ์นœ๊ตฌ์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค ! ์ œ๊ฐ€ ํ•˜๊ณ ์žˆ๋Š” ํ”„๋กœ์ ํŠธ ์ฝ”๋“œ์— ์“ฐ์ด๋Š” ๊ฒƒ์„ ๋ณด๊ณ  ์ €๋„ ๊ถ๊ธˆํ•ด์ ธ์„œ ๊ฐ€์ ธ์™€๋ดค์Šต๋‹ˆ๋‹ค ! ๐ŸŒ€ @discardableResult - ์˜๋ฏธ: ๊ฒฐ๊ณผ๊ฐ’์„ discardable ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ฆ‰ ๊ฒฐ๊ณผ๊ฐ’์„ ๋ฒ„๋ฆด ์ˆ˜ ์žˆ๋‹ค. ๋ผ๋Š” ์˜๋ฏธ - ํ•จ์ˆ˜์˜ return๊ฐ’์„ discadable ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค -> return ๊ฐ’์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•„๋„ warning ๋ฉ”์„ธ์ง€๋ฅผ ๋‚˜์˜ค์ง€ ์•Š๋„๋ก ์„ค์ • ๊ฐœ๋ฐœ์„ ํ•˜๋‹ค๋ณด๋ฉด ์—ฌ๋Ÿฌ๊ฐ€์ง€ Warning์„ ๋ณด๊ฒŒ๋˜๋Š”๋ฐ์š” ! ใ…Žใ…Ž ๊ทธ์ค‘์—์„œ ์•„๋ž˜์™€ ๊ฐ™์ด Result of call to '์–ด์ฉŒ๊ตฌ' is unused ๋ผ๋Š” ๊ฒฝ๊ณ ๋ฅผ ๋ณธ์ ์ด ์žˆ์„ ๊ฑฐ์—์š” ! ๊ฒฐ๊ณผ๋ฅผ return ํ–ˆ์ง€๋งŒ ๊ฒฐ๊ณผ๊ฐ’์ด ์‚ฌ์šฉ๋˜์ง€ ์•Š์•˜์„ ๊ฒฝ์šฐ์— ๋œจ๋Š” ๊ฒฝ๊ณ ์ž…๋‹ˆ๋‹ค ! ๊ทธ๋ ‡์ง€๋งŒ.. ! ..

Language/Swift 2022. 2. 8. 10:37