반응형
What is mutating function?
If you ever used structure or class, you might heard of mutating keyword.
You can use the mutating keyword in the instance method to modify the properties.
If you have tried using the mutating keyword in class methods,
the compiler will saying there is something wrong.
2020/10/01 - [개발/ios] - Swift structure vs class
The properties of value types cannot be modified within its instance methods by default..
With mutating keyword, your method have the ability to mutate the values of the properties.
Simple example of stack implementation using mutating functions.
Thanks for reading!
Happy coding :)
반응형
그리드형
'개발 > swift' 카테고리의 다른 글
Swift how to fix autolayout issue? (0) | 2020.11.05 |
---|---|
Swift UICollectionView performBatch (0) | 2020.11.04 |
Swift How to manage keyboard with UIScrollView? (0) | 2020.10.29 |
Swift How to save data? Userdefaults (0) | 2020.10.28 |
Swift How to set build environment? (0) | 2020.10.25 |