Loading…

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.

Suggest An Answer

No suggestions avaliable!

Latest post from Swift Interview Questions

Ask Question