What are functions different from methods?
Functions
- Self-contained code that performs a specific task.
- Identified by their name to call whenever a task is required.
- To declare a function, use func.
- Use . -> to separate function parameters parenthesis and return type.
Methods
- Associated with a particular type.
- The first parameter name is given by default.
- Enumeration and Structure define methods.
BY Best Interview Question ON 13 Jan 2019