我确信,这个问题有一些改动,但关于SO的所有其他类似问题似乎更为复杂,涉及穿透阵列和其他形式的数据。 我的设想非常简单,因此我希望有一个简单/可取的解决办法。
是否有办法可以创造匿名职能,还是通过一个密码线作为另一个职能点?
就我而言,我有一系列不同的行动。 在每项法典之前和之后,我想要完成的任务,这种任务永远不会改变。 我不想重复最初的法典和最后的法典,而是想写出一个功能点,作为参数,按必要的顺序执行所有法典。
我的问题是,这并不值得为每项行动确定30项职能,因为它们是每一条码。 如果我无法创造匿名职能,我是否能够简化我的《刑法》?
If my request isn t entirely clear. Here s a bit of pseudo-code for clarification. My code is much more meaningful than this but the code below gets the point accross.
void Tests()
{
//Step #1
printf("This is the beginning, always constant.");
something_unique = a_var * 42; //This is the line I d like to pass as an anon-function.
printf("End code, never changes");
a_var++;
//Step #2
printf("This is the beginning, always constant.");
a_diff_var = "arbitrary"; //This is the line I d like to pass as an anon-function.
printf("End code, never changes");
a_var++;
...
...
//Step #30
printf("This is the beginning, always constant.");
var_30 = "Yup, still executing the same code around a different operation. Would be nice to refactor..."; //This is the line I d like to pass as an anon-function.
printf("End code, never changes");
a_var++;
}