What does "- & gt;" mean quick expression when declaring functions?

example function

func example(titles: [String]) `->` [UIButton] { } 

and where can I find more documents on this topic (documents related to declaring functions in swift)?

+6
source share
2 answers

Fast function declarations do not have > - someone was looking for HTML rendering on the page you read. It was assumed that this would be -> (an arrow made up of hypen and a larger operator), which is used to indicate the return type of the function.

The text was supposed to read

 func example(titles: [String]) -> [UIButton] { } 

This means that the example function has one parameter named titles type [String] (an array of String) and returns [UIButton] (an array of UIButton).

+16
source

Assuming you're talking about -> , the part after that denotes the return value of the function.

+2
source

Source: https://habr.com/ru/post/989332/


All Articles