Swift: Enums that use closures?

前端 未结 2 1248
轮回少年
轮回少年 2021-02-13 02:31

I’m creating an application where an unlimited amount of rules could be applied to an unlimited amount of nodes.

I\'m planning on using core data as the datastore and

2条回答
  •  无人及你
    2021-02-13 03:22

        enum FunctionEnum
       {
         case binaryOperation((Double,Double)->Double)
         constant(Double)
       }
    

    1.you can associate values to enum cases , hence it also has type here for example binaryOperation is of type ((Double,Double)->Double) which means its of type a closure which accepts two doubles and return one

提交回复
热议问题