ios - Type of Generic -


can somehow check type of t. want check type array or else.

func request<t: mappable>(completionhandler: (result<t>) -> void) {  } 

one way overload method, so:

private func request<t: mappable>(isarray: bool, completionhandler: (result<t>) -> void) {   if isarray {     print("is array")   } else {     print("is not array")   } }  func request<t>(completionhandler: (result<array<t>>) -> void) {   request(isarray: true, completionhandler: completionhandler) }  func request<t: mappable>(completionhandler: (result<t>) -> void) {   request(isarray: false, completionhandler: completionhandler) } 

i'm assuming somewhere have defined:

extension array: mappable {} 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -