Methods belong to classes, structs, and enums, whereas functions do not.
Methods always belong to a data type, they have a concept of self that functions do not. This is a special value passed in by Swift, and it refers to whatever instance the method was called on.
Swift uses the same keyword, func, for both functions and methods.
No comments:
Post a Comment
Thanks