Open zxTheX opened 1 year ago
#if UNITY_EDITOR // v1 No.6 [MethodAPI] [APIDescriptionCN("遍历 List (可获得索引)")] [APIDescriptionEN("foreach List (can get index)")] [APIExampleCode(@" var testList = new List<string> {""a"", ""b"", ""c"" }; testList.Foreach((c,index)=>Debug.Log(index)); // 1, 2, 3, ")] #endif public static void ForEach<T>(this List<T> list, Action<int, T> action) { for (var i = 0; i < list.Count; i++) { action(i, list[i]); } }
方法传参的action中index在前,而注释里的index在后。注释和API需要改变其中一个,否则ForEach<int>的调用会产生混淆 ps:对于js/ts index在后是正确的,而考虑兼容性就不方便改变已有API,但二者必改其一
ForEach<int>
方法传参的action中index在前,而注释里的index在后。注释和API需要改变其中一个,否则
ForEach<int>
的调用会产生混淆 ps:对于js/ts index在后是正确的,而考虑兼容性就不方便改变已有API,但二者必改其一