对于下面的代码:
let services: [MyServices] = [
MyService(),
#if DEBUG
DebugService(),
#endif
]
我收到编译器错误:
表达式无法解析: 错误:MyPlayound.playround:375:5:错误:容器文本中需要表达式 #IF DEBUG ^
错误:MyPlayarg.playround:376:19:错误:一行上的连续语句必须用‘;’分隔 DebugService()、 ^ ;
错误:MyPlayound.playround:376:19:错误:预期的表达式 DebugService()、 ^
错误:MyPlayound.playround:378:1:错误:预期的表达式 ]
但同样的代码可以在Objective-C中运行
NSArray *array = @[
@"11",
#if DEBUG
@"debug",
#endif
@"22"
];
这是编译器错误还是预期行为?谢谢.