Group Group Group Group Group Group Group Group Group

MathLibrary.swift

Going through MathLibrary.swift (chapter 5) I noticed the following simple function

   static func identity() -> float4x4 {
      matrix_identity_float4x4
   }

but it surprised me because there was no return keyword. Is this because there are no other statements as in simple closures? Or is something else going on?

@tchelyzt Swift 5.1 uses implicit returns in single line functions:

https://www.raywenderlich.com/4187396-what-s-new-in-swift-5-1#toc-anchor-004

I hope it helps!

It’s new in Swift 5 (I think). If there is a single statement in a closure, you don’t need a return.

Oops - didn’t see Cosmin’s better answer :slight_smile:

Thank you both. It looked like that to me but I’d never realised it was generally available. It’s quite curious looking and I would say I’d prefer to put the return for clarity.