Why does it compile and work?
I can't find any info on this.
我给你举个例子.基于SWIFT语法库.
@CodeBlockItemListBuilder statementsBuilder: () -> CodeBlockItemListSyntax
所以,假设我们有一个函数,它有这样一个参数.该函数需要一个带有CodeBlockItems的闭包,因此ResultBuilder将构建CodeBlockItemList.
myFunction {
item1
item2
item3
...
}
似乎我也可以将itemList(结果类型CodeBlockItemListSyntax
的对象)传递给它:
myFunction {
itemList
}
I don't understand why we're allowed to do that. Why does it work? How does it work?!
In fact, we even can mix Item with ItemList objects! But output is a little bit strange... which confuses me even more.
P.S.
Was pretty surprised that there still doesn't exist neither "result-builder" nor "swift-syntax" tags in StackOverFlow.