Notice
Recent Posts
Recent Comments
Link
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

sanichdaniel의 iOS 개발 블로그

Operator Overloading 본문

swift

Operator Overloading

sanich8355 2020. 10. 16. 20:42

Operator Overloading

Class, struct는 기존에 존재하는 operator에 대한 자신만의 구현을 제공할수 있다.

이것을 operator overloading이라 한다.

operator은 +, -, *, /, %, = 같은 심볼들로 값을 체크하거나, 수정, 합치는데 사용된다

함수를 사용하는것보다 더 간결하게 코드를 표현할수 있을때 사용된다

Equatable 프로토콜 구현이 사실 operator overloading이었다!

 

 

출처

www.hackingwithswift.com/example-code/language/how-to-use-operator-overloading

'swift' 카테고리의 다른 글

expression, statement, literal  (0) 2020.10.24
양방향 타입추론  (0) 2020.10.22
빌드 타임 개선  (0) 2020.10.14
Pure functions in swift  (0) 2020.10.14
일급 시민 함수 - swift  (0) 2020.10.14