瀏覽代碼

Replace C# if statement with switch statement to match GDScript (#5018)

hpnrep6 4 年之前
父節點
當前提交
783f295af2
共有 1 個文件被更改,包括 11 次插入7 次删除
  1. 11 7
      getting_started/workflow/best_practices/data_preferences.rst

+ 11 - 7
getting_started/workflow/best_practices/data_preferences.rst

@@ -257,14 +257,18 @@ tree structures.
 
         public override void Notification(int what)
         {
-            if (what == NotificationPredelete)
+            switch (what)
             {
-                foreach (object child in _children)
-                {
-                    TreeNode node = child as TreeNode;
-                    if (node != null)
-                        node.Free();
-                }
+                case NotificationPredelete:
+                    foreach (object child in _children)
+                    {
+                        TreeNode node = child as TreeNode;
+                        if (node != null)
+                            node.Free();
+                    }
+                    break;
+                default:
+                    break;
             }
         }
     }