Search code examples
swiftios8xcode6

what does "->" mean in swift?


I was following a Swift tutorial, and in a function it is declared as:

func clamp (min: CGFloat, max: CGFloat, value: CGFloat) -> CGFloat{}

what does -> mean?


Solution

  • That is called the return arrow and indicates that the function returns a value, whose type follows the ->. It is optional (along with the type that follows it) if the function returns no value.

    More info at Defining and Calling Functions