考虑以下代码:
int totalLength = 0;
int partLength = 0;
for(; totalLength < SOME_CONST; totalLength += partLength, partLength = 0)
{
//partLength may be increased here
}
在这种特殊情况下,我可以假设partLength将被设置为0,它将被添加到totalLength(因此,如果partLength将在循环体中增加,我将不会将0添加到totalLength循环结束)?我读过关于c ++序列等的内容,但没有找到任何明确的答案。
答案 0 :(得分:5)
是。逗号运算符的左侧在右侧之前排序。在totalLength += partLength
执行partLength = 0
之前,我会对//Capture Screen
func capture()->UIImage {
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, false, UIScreen.mainScreen().scale)
self.view.layer.renderInContext(UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}
进行全面评估。