Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Updated 31 October 2022
The Never keyword is a special return type in Swift. When this function call occurs, it tells the compiler that exec will never return
According to Apple:-
“The return type of functions that do not return normally, that is, a type with no values.”
Never keyword used by fatalError() and preconditionFailure() functions.
fatalError()
preconditionFailure()
We can use it as a return type when declaring a method, closure, or function that unconditionally throws an error, traps, or otherwise does not terminate.
func method1() -> Never {
unc
method1() ->
Never
{
fatalError("Something very, very bad happened")
}
The first note (with regard to secondary error treatment) is perhaps particularly important. A function can never have complex arguments and throws – not necessarily crashes.
Let’s look at some interesting use cases and compare between never and void
Comparision between NEVER and VOID return type :
VOID:
That’s all for this article.
We hope you liked the article.
Please visit my other blogs here.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.