菜鸟教程小白 发表于 2022-12-13 13:44:51

ios - 这个方便是什么意思?


                                            <p><pre><code>_labelView = ({
    UIView * labelView = [initWithFrame:CGRectMake(0, 0, _midView.frame.size.width, _midView.frame.size.height)];
    for (int i = 0;i &lt; titleArr.count ; i++) {
       andFrame:CGRectMake(0, i*_height, self.frame.size.width, _height) andColor:]];
    }
    labelView;
});
</code></pre>

<p>为什么“labelView”可以这样赋值?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>这是 <a href="https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs" rel="noreferrer noopener nofollow">statement expression</a> , 括在括号中的复合语句,用作表达式。这是模式的 GCC 描述:</p>

<blockquote>
<p>A compound statement enclosed in parentheses may appear as an expression in GNU C. This allows you to use loops, switches, and local variables within an expression.</p>

<p>Recall that a compound statement is a sequence of statements surrounded by braces; in this construct, parentheses go around the braces. For example:</p>

<pre><code>({ int y = foo (); int z;
    if (y &gt; 0) z = y;
    else z = - y;
    z; })
</code></pre>

<p>is a valid (though slightly more complex than necessary) expression for the absolute value of <code>foo ()</code>.</p>

<p>The last thing in the compound statement should be an expression followed by a semicolon; the value of this subexpression serves as the value of the entire construct. (If you use some other kind of statement last within the braces, the construct has type void, and thus effectively no value.)</p>
</blockquote>

<p>语句表达式最常见的用法是在 <code>#define</code> 宏中(参见 <a href="https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs" rel="noreferrer noopener nofollow">GCC discussion</a>),在该上下文之外并不常见。 </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 这个方便是什么意思?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/34984243/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/34984243/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 这个方便是什么意思?