# Problem with ternary operator and break

**URL:** https://forum.kirupa.com/t/problem-with-ternary-operator-and-break/323543
**Category:** Uncategorized
**Created:** [July 6, 2011, 6:17am UTC](https://forum.kirupa.com/t/problem-with-ternary-operator-and-break/323543 "2011-07-06T06:17:06Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![darquin](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/darquin/32/567_2.png) [@darquin](https://forum.kirupa.com/u/darquin)
#### Post date: [July 6, 2011, 6:17am UTC](https://forum.kirupa.com/t/problem-with-ternary-operator-and-break/323543/1 "2011-07-06T06:17:06Z")

</div>

I ran into a problem where the following works fine…

```auto

if (nextJewel.gemType == jewel.gemType){
     len++;
}else{
     break;
}

```

but the following…

```auto

(nextJewel.gemType == jewel.gemType) ? len++ : break;

```

produces a 1084: Syntax error: expecting identifier before break.

I’m not sure why. It’s a minor problem, but if someone knows how to fix it or why it does that, I’d appreciate it.

Thanks.
