Skip to content

Latest commit

 

History

History

section22-exeception_handling-question

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Exception Handling 1 ~ 3

1) What is an Exception? What is Exception Handling?

Answer:

  • Exception is a Runtime Error.
  • The process of Handling the runtime errors is known as Exception Handling.
  • Use do, try, catch, throw and throws to achieve exception handling.

2) What are the advantages of exception handling?

Answer:

  • Exception Handling is helpful to co-workers of a team to indicate that there is some **dangerous code, “**please be cautious while using that piece of code”.

3) What is defer keyword?

Answer:

  • A block of code which gets executed just before the execution control comes out of that method.
struct AnyStruct {

	func method() {
			defer {
					print("This is the last statement which gets executed")
			}

			print("Run first")
			print("Run second")
			print("Run third")
	}

}

let executor: AnyStruct = AnyStruct()
executor.method()
// Run first
// Run second
// Run third

Table Of Contents

Section 1, Data Type

Section 2, Operator

Section 3, Conditional Statement

Section 4, Enum

Section 5, functions

Section 6, struct

Section 7, initializers

Section 8, closures

Section 9, OOP

Section 10, static type vs dynamic type

Section 11, optional

Section 12, generic

Section 13, subscript

Section 14, access specifier

Section 15, higher order function

Section 16, delegate

Section 17, extension

Section 18, Memory Management

Section 19, protocols

Section 20, collections

Section 21, KVO and KVC

Section 22, Exception Handling

Section 23, Framework

Section 24, Objective-C