最近,在进行编码时,我一直在发现自己一遍又一遍地为循环标题编写完全相同的内容:
for (int i = 0; i < [somevalue]; i++)
{
[other code]
}
Run Code Online (Sandbox Code Playgroud)
有没有人知道重载for循环的方法,或者定义另一个关键字以便它需要一个数字并通过给定的for循环来提供它,以缩写为:
for ([somevalue])
{
[other code]
}
Run Code Online (Sandbox Code Playgroud)
要么
nfor ([somevalue])
{
[other code]
}
Run Code Online (Sandbox Code Playgroud)
因为只是一直编写for(12)并让它迭代12次代码会更好