[英]In IDE why doesn’t ;(Semicolons) come automatically?
如果我們寫 printf 那么我們會自動得到“()” 但是為什么分號沒有出現。 我認為它會解決很多錯誤。
對於 printf 我們得到printf()
我們應該得到printf();
所以這是一個很好的建議,但通常可能有這樣的函數或對象(來自 OOP 概念)可能有另一個 function 跟隨它。
示例(在 Javascript 中):
const ref = firestore.collection(db).get(); // get() fn alone
const ref = firestore.collection(db).get().then(); // get() fn followed by then()
或者可以在行尾有一個字符。
例子:
for(int i=0; i<5; i++){ // '{' present. ';' will cause error
printf("Hi"); // ';' required
} // '}' present. ';' will cause error
因此,每次編譯器檢測到缺少分號時拋出錯誤是一種更有效的方法。 此外,當您使用 Python 等語言或 Node.JS 或 React.JS 等框架/庫時,您不需要完全使用分號。
並非所有有效的 c 語句都以“;”結尾。 一些例子是:
#include <file> //can't put ; here
macro(arg) //won't work here too
if(true) //wont work here
之類的。 畢竟 C 不像 python 那樣構建。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.