Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Compiling in xCode using Swift 2 //:Below you will see a list of common HTTP res

ID: 3750537 • Letter: C

Question

Compiling in xCode using Swift

2 //:Below you will see a list of common HTTP response codes and their corresponding english meanings (messages) 3 / HTTP Response Examples 4 ### Codes & Messages 5 Success Codes 200OK 201-Created 202-Accepted 10 Client Errors 12 13 480 Bad Request 494-Not Found Server Error 500Internal Server Error 502Bad Gateway 15 16 17 18 //: Given some tuple variable named respon seCode of type (int, String) write a switch statement that uses advanced switch techniques (value binding, where statements, etc) to evaluate the tuple. If any of the Success codes are found print the word "Success".If an error code is found, print the type of error (client or server), the code and its associated message. If the code is not one of those displayed above, print a generic message indicating some unknown problem occurred. This should all1 be done within a single switch statement.

Explanation / Answer

switch(responseCode)

{

case(201...202,_):

println("Success")

case let(x,y) where x==400 || x==404:

println("Client Error (x) - (y)")

case let(x,y) where x==500 || x==502:

println("Server Error (x) - (y)")

default:

println("Some unknown problem occurred.")

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote