在斯威夫特,你不能在協議定義本身定義的功能或屬性的默認實現,即: protocol Container {
//These are fine
associatedtype Item
mutating func append(_ item: Item)
var count: Int { get set }
subscript(i: Int) -> I
我有一個數組返回基準的函數(全局用於簡化起見,實際上這些陣列是一些大的樹結構的元素): $array1;
$array2;
function &foo($arg){
//deduce from $arg reference to which array should be returned
if(...) {
global $array1;
retur