About Closure with $0 and $1

Hello all. I wanna testing with $0 and $1, when i use it for closure. I search in case implemtentaion with arrayVariabel.sorted(by:{$0 < $1}). So how to implement it in that case? thank u

This is a good question, it highlights a few things about why Swift is so good:

  1. Closure are great at making simple and readable code.
  2. It’s great at inferring types given some amount of type of information, for example, in your first multiplyClosure above, it is able to infer that you are multiplying two Int values, since the return is Int. In the second multiplyClosure, Swift has no idea about the types, thus can’t apply an operator.
  3. The data.sorted closure works becase the sorted syntax requires a certain closure and pre-defines its data types.
  4. Swift is typed.