[Solved] Is it complusory to use “in” keyword in closure? If no then what is the syntax wise difference between closure and computed property in swift?


greet is a closure. A computed property is

var greet : Int {
  return 4+3
}

greet // without parentheses

And “in” in closure is also not compulsory if a parameter is passed (by the way the return keyword is not compulsory)

var greet = { x in
  4+x
}

greet(4)

unless you use the shorthand syntax

var greet = {
   4+$0
}

greet(4)

solved Is it complusory to use “in” keyword in closure? If no then what is the syntax wise difference between closure and computed property in swift?