Error handling using throws and do-catch in Swift

Example of using throws and do-catch and try to handle errors in Swift

Throwing functions in Swift



To indicate that a function can throw error you just add the word “throws” after its parameters and before its return type.

It is then called a throwing function. Continue reading “Error handling using throws and do-catch in Swift”

What exactly are Generics

In fact Array and Dictionary are generic collections, this is why you can create an Array of Int , String or any other type

What are Generics



Generics are one of the most powerful features of Swift, It allows you to create flexible Functions and Types that can work with any type.

If you used Array or Dictionary before in Swift then you already knows about Generics.
In fact Array and Dictionary are generic collections, this is why you can create an Array of Int , String or any other type and the same with Dictionary. Continue reading “What exactly are Generics”