If you are interested in programing so of course, you’ve heard before about functions but maybe closure expression will be new for you or you will be a little bit confused about it so before thinking a lot about anything let’s dive into these two great concepts to check the difference.

1- Functions

Functions are considered as a block of code that you can call by just mentioning its name, functions can take parameters or can not, also you can return a value or not as it depends on your code. Let’s take a small example for a very simple function:


In programmer’s life there is almost no code without structs or classes so while navigating in any code you need to be aware of the differences between them.

The first and the most important thing you need to know is that class is a reference type and struct is value type. You introduce structures with struct keyword and classes with the class keyword.

Let’s start with syntax highlighted for each:

1- Struct:

struct myStruct {  
// Definition

2- Class:

class myClass { 
// Definition

Common Traits for both classes and structs:

  1. Have properties and store values
  2. Both can…

The first thing comes to your mind after seeing the title and picture that you are comparing between two persons from their strength but in programming languages especially swift you will have another point of view, you are still comparing but not persons but references and the difference here that you have a superhero by your side which called ARC “Automatic Reference Counting”

ARC is helping to track and manage memory to free it from unused references to be able to avoid retain cycle (Memory leak) which happens when references don’t be de-allocated by ARC. …

If you are interested in iOS Development or like to start using Swift then you need to know that you will meet some symbols that you may not meet before, marks like question mark ? or exclamation mark !.

Optional is a great feature produced by swift to avoid the nil values for the variables, and you can discover it by seeing a question mark ? which means that this variable is optional or by seeing ! mark which means that you don’t need this variable to be optional anymore.

Suppose you have some movies but each one has its…

After finishing this article you will be able to know the differences between array and set in swift language.

Let’s use a simple example to be able to understand it in an easy way:

Suppose we are in a small school and you need to initialize each class with its students but here we have only three classes as we start as a small school:

var classA = ["Max", "Niro", "Geace","Clary","Maghnos","Raul","Sam"]

var classB : [String] = []
classB = ["Asta","Neur","Magnam","Rose","Santiago","Alex"]

var classC: Array<String> = Array()
classC = ["Niro", "Rose","Sam","Muller","Nymar", "Joe","Bella"]

let classD = ["Scoot","Lydia","Alex","Sam","Clary","Bella","Alison","Sepastian"]

In the above block of code…

Ahmed Menaim

iOS / Software Engineer / Building iOS Apps / Spread knowledge

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store