Skip to content

Commit 245a5f4

Browse files
committed
Added rules on ternary operator to style guide
1 parent db4dbfd commit 245a5f4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

cppguide.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,12 @@ <h3 id="Conditionals">Conditionals</h3>
18561856

18571857
</div>
18581858

1859+
<h3 id="Ternary Operator">Ternary Operator</h3>
1860+
1861+
<div class="summary">
1862+
<p>The ternary operator is useful for condensing branching assignments into single lines. It should only be used when all parts of the ternary are simple expressions (only addition/subtraction/etc., no object allocation). Ternary operator usage may not be nested.</p>
1863+
</div>
1864+
18591865
<h3 id="Loops_and_Switch_Statements">Loops and Switch Statements</h3>
18601866

18611867
<div class="summary">

javaguide.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ <h1>WPILib Java Style (Based on the
158158
<dd class="toc3">
159159
<a href="#s4.8.8-numeric-literals">4.8.8 Numeric Literals</a>
160160
</dd>
161+
<dd class="toc3">
162+
<a href="#s4.8.9-ternary-operator">4.8.9 Ternary Operator</a>
163+
</dd>
161164
</dl>
162165
</td><td>
163166
<dl>
@@ -618,7 +621,11 @@ <h4>4.8.7 Modifiers&nbsp;<a href="#s4.8.7-modifiers"><img height="21" width="21"
618621
<h4>4.8.8 Numeric Literals&nbsp;<a href="#s4.8.8-numeric-literals"><img height="21" width="21" src="guidelink.png"/></a></h4>
619622
<p><code>long</code>-valued integer literals use an uppercase <code>L</code> suffix, never
620623
lowercase (to avoid confusion with the digit <code>1</code>). For example, <code>3000000000L</code>
621-
rather than <code class="badcode">3000000000l</code>.</p><a name="naming"/><a name="s5-naming"/>
624+
rather than <code class="badcode">3000000000l</code>.</p>
625+
<a name="s4.8.9-ternary-operator"/>
626+
<h4>4.8.9 Ternary Operator&nbsp;<a href="#s4.8.9-ternary-operator"><img height="21" width="21" src="guidelink.png"/></a></h4>
627+
<p><p>The ternary operator is useful for condensing branching assignments into single lines. It should only be used when all parts of the ternary are simple expressions (only addition/subtraction/etc., no object allocation). Ternary operator usage may not be nested.</p>
628+
<a name="naming"/><a name="s5-naming"/>
622629
<h2>5 Naming&nbsp;<a href="#s5-naming"><img height="21" width="21" src="guidelink.png"/></a></h2>
623630
<a name="s5.1-identifier-names"/>
624631
<h3>5.1 Rules common to all identifiers&nbsp;<a href="#s5.1-identifier-names"><img height="21" width="21" src="guidelink.png"/></a></h3>

0 commit comments

Comments
 (0)