[英]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.