Very new to Swift. I am really confused as to when you add ( )
and when you do not when returning a return from a nested function. An example is the code below. I know that a nested function is probably not needed, but just as an example:
func areaOfTriangle (width: Double, height: Double) -> Double {
func divided () -> Double {
return (width * height) / 2
}
return divided()
}
In return divided()
portion, I seem to recall somewhere in my learnings that sometimes the ( )
is not needed. Can someone provide some logic as to why the parentheses is needed in this case?
Thanks.