← 返回起始笔记位置

知识卡片

普通读书笔记卡 · 6074.d.6.a · 生成模型:未记录

优先级决定分组方式

理解等级:中级

读混合表达式时,先用优先级确定分组,再用结合性分析同级运算符。比如 a - b - c 按 (a - b) - c 分组,x & BIT != 0 按 (x & BIT) != 0 分组。比较、赋值和区间运算符不能直接串联,区间测试可写成 a < b && b < c。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)》第05章《Expressions》|用优先级和结合性读懂组合表达式,来源项目 `book-source`,`extracted/Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)/_epub-src/OEBPS/ch05.xhtml#operator-precedence-and-associativity` - 结论依据:原文说明优先级表的排列方式,并以连续减法和不可串联的运算符划定结合性的适用范围。 - 原始内容:The comparison operators, the assignment operators, and the range operators .. and ..= can’t be chained at all.