Function not working; Error: unexpected non-void return value in void function

I'm working on a lesson concerning functions in Swift and attempted to practice by creatinga function that would convert yards to meters. But I keep getting an error code on line 76 that I tried looking up to no avail. I've been looking at the code and it seems correct to me. Could someone please let me know what I'm doing incorrectly here that is yielding this error? The error in the debug area states:

Playground execution failed: error: MyPlayground.playground:76:12: error: unexpected non-void return value in void function
return convertedAmount
       ^~~~~~~~~~~~~~~

I've attached a screenshot below. Please help. Thank you.

Your function seems to be lacking a return type. Try this function signature instead:

func convertYardToMeters(using yardage: Double) -> Double {
   ...
}

(Note the added -> Double at the end.)

2 Likes

I just realized what I did wrong. And that someone else noticed it here too! Thank you!

Can you file a bug? The compiler could help you out here by offering to make the function return the type.

3 Likes

I'll do so, thank you Jordan!

1 Like