George Brett Pine Tar Incident What is the pine tar incident? Yankees manager Billy Martin cited to the umpires a rule that stated that any foreign substance on a bat could extend no further than 18 inches from the knob. What happened after that? The umpires measured the amount of pine tar, a legal substance used by hitters to improve their grip, on Brett's bat; the pine tar extended about 24 inches. What did he do? The home plate umpire, Tim McClelland, signaled Brett out, ending the game as a Yankees win. What did Brett do? an enraged Brett charged out of the dugout sprinting directly toward McClelland and had to be physically restrained by two umpires and a Royals coach. What were the consequences? The Royals protested the game, and American League president Lee MacPhail upheld the protest, What was the resolution? Amid much controversy, the game was resumed on August 18 from the point of Brett's home run and ended with a Royals win. What was the impact? In 1985, Brett had another brilliant season in which he helped propel the Royals to their second American League Championship.
What else changed as a result?
What else changed as a result of the Pine Tar Incident in addition to Brett's American League Championship win?
On July 24, 1983, the Royals played the Yankees at Yankee Stadium. In the top of the ninth inning with two out, Brett hit a go-ahead two-run homer off of Goose Gossage to put the Royals up 5-4. Upon Brett crossing the plate, Yankees manager Billy Martin cited to the umpires a rule that stated that any foreign substance on a bat could extend no further than 18 inches from the knob. The umpires measured the amount of pine tar, a legal substance used by hitters to improve their grip, on Brett's bat; the pine tar extended about 24 inches. The home plate umpire, Tim McClelland, signaled Brett out, ending the game as a Yankees win. In a now famous image, an enraged Brett charged out of the dugout sprinting directly toward McClelland and had to be physically restrained by two umpires and a Royals coach.  The Royals protested the game, and American League president Lee MacPhail upheld the protest, reasoning that the bat should have been excluded from future use but the home run should not have been nullified. Amid much controversy, the game was resumed on August 18 from the point of Brett's home run and ended with a Royals win.  In 1985, Brett had another brilliant season in which he helped propel the Royals to their second American League Championship. He batted .335 with 30 home runs and 112 RBI, finishing in the top 10 of the league in 10 different offensive categories. Defensively, he won his only Gold Glove, which broke Buddy Bell's six-year run of the award. In the final week of the regular season, he went 9-for-20 at the plate with 7 runs, 5 homers, and 9 RBI in six crucial games, five of them victories, as the Royals closed the gap and won the division title at the end. He was MVP of the 1985 playoffs against the Toronto Blue Jays, with an incredible Game 3. With KC down in the series two games to none, Brett went 4-for-4, homering in his first two at bats against Doyle Alexander, and doubled to the same spot in right field in his third at bat, leading the Royals' comeback. Brett then batted .370 in the World Series against the St. Louis Cardinals including a four-hit performance in Game 7. The Royals again rallied from a 3-1 deficit to become World Series Champions for the first time in Royals history. CANNOTANSWER
CANNOTANSWER
George Howard Brett (born May 15, 1953) is an American former professional baseball player who played 21 seasons, primarily as a third baseman, in Major League Baseball (MLB) for the Kansas City Royals.

Brett's 3,154 career hits are second most by any third baseman in major league history (after Adrian Beltre's 3,166) and rank 18th all-time. He is one of four players in MLB history to accumulate 3,000 hits, 300 home runs, and a career .300 batting average (the others being Hank Aaron, Willie Mays, and Stan Musial). He was inducted into the Baseball Hall of Fame in 1999 on the first ballot and is the only player in MLB history to win a batting title in three different decades. He was also a member of the Royals' 1985 World Series victory over the St. Louis Cardinals.

Brett was named the Royals' interim hitting coach in 2013 on May 30, but stepped down from the position on July 25 in order to resume his position of vice president of baseball operations.

Early life
Born in Glen Dale, West Virginia, Brett was the youngest of four sons of a sports-minded family which included Ken, the second oldest, a major league pitcher who pitched in the 1967 World Series at age 19. Brothers John (eldest) and Bobby had brief careers in the minor leagues. Although his three older brothers were born in Brooklyn, George was born in the northern panhandle of West Virginia.

Jack and Ethel Brett then moved the family to the Midwest and three years later to El Segundo, California, a suburb of Los Angeles, just south of Los Angeles International Airport. George grew up hoping to follow in the footsteps of his three older brothers. He graduated from El Segundo High School in 1971 and was selected by the Kansas City Royals in the second round (29th overall) of the  baseball draft. He was high school teammates with pitcher Scott McGregor.       He lived in Mission Hills, Kansas when he moved to the Midwest.

Playing career

Minor leagues
Brett began his professional baseball career as a shortstop, but had trouble going to his right defensively and was soon shifted to third base. As a third baseman, his powerful arm remained an asset, and he remained at that spot for more than 15 years. Brett's minor league stops were with the Billings Mustangs for the Rookie-level Pioneer League in 1971, the San Jose Bees of the Class A California League  in 1972, and the Omaha Royals of the Class AAA American Association in 1973, batting .291, .274, and .284, respectively.

Kansas City Royals (1973–1993)

1973
The Royals promoted Brett to the major leagues on August 2, 1973, when he played in 13 games and was 5 for 40 (.125) at age 20.

1974
Brett won the starting third base job in 1974, but struggled at the plate until he asked for help from Charley Lau, the Royals' batting coach. Spending the All-Star break working together, Lau taught Brett how to protect the entire plate and cover up some holes in his swing that experienced big-league pitchers were exploiting. Armed with this knowledge, Brett developed rapidly as a hitter, and finished the year with a .282 batting average in 113 games.

1975–1979
Brett topped the .300 mark for the first time in 1975, hitting .308 and leading the league in hits and triples. He then won his first batting title in 1976 with a .333 average. The four contenders for the batting title that year were Brett and Royals teammate Hal McRae, and Minnesota Twins teammates Rod Carew and Lyman Bostock. In dramatic fashion, Brett went 2 for 4 in the final game of the season against the Twins, beating out his three rivals, all playing in the same game. His lead over second-place McRae was less than .001. Brett won the title when a fly ball dropped in front of Twins left fielder Steve Brye, bounced on the Royals Stadium AstroTurf and over Brye's head to the wall; Brett circled the bases for an inside-the-park home run. McRae, batting just behind Brett in the line up, grounded out and Brett won his first batting title.

From May 8 through May 13, 1976, Brett had three or more hits in six consecutive games, a major league record. A month later, he was on the cover of Sports Illustrated for a feature article, and made his first of 13 All-Star teams. The Royals won the first of three straight American League West Division titles, beginning a great rivalry with the New York Yankees—whom they faced in the American League Championship Series each of those three years. In the fifth and final game of the 1976 ALCS, Brett hit a three-run homer in the top of the eighth inning to tie the score at six—only to see the Yankees' Chris Chambliss launch a solo shot in the bottom of the ninth to give the Yankees a 7–6 win. Brett finished second in American League MVP voting to Thurman Munson.

A year later, Brett emerged as a power hitter, clubbing 22 home runs, as the Royals headed to another ALCS. He is shown in archive footage batting against the New York Yankees in Game Two of those playoffs in the 2007 television miniseries The Bronx is Burning. In Game 5 of the 1977 ALCS, following an RBI triple, Brett got into an altercation with Graig Nettles which ignited a bench-clearing brawl.

In , Brett batted .294 (the only time between 1976 and  in which he did not bat at least .300) in helping the Royals win a third consecutive AL West title. However, Kansas City once again lost to the Yankees in the ALCS, but not before Brett hit three home runs off Catfish Hunter in Game Three, becoming the second player to hit three home runs in an LCS game (Bob Robertson was the first, having done so in Game two of the 1971 NLCS).

Brett followed with a successful 1979 season, in which he finished third in AL MVP voting. He became the sixth player in league history to have at least 20 doubles, triples and homers all in one season (42–20–23) and led the league in hits, doubles and triples while batting .329, with an on-base percentage of .376 and a slugging percentage of .563.

1980
All these impressive statistics were just a prelude to , when Brett won the American League MVP and batted .390, a modern record for a third baseman. Brett's batting average was at or above .400 as late in the season as September 19, and the country closely followed his quest to bat .400 for an entire season, a feat which has not been accomplished since Ted Williams in .

Brett's 1980 batting average of .390 is second only to Tony Gwynn's  average of .394 (Gwynn played in 110 games and had 419 at-bats in the strike-shortened season, compared to Brett's 449 at bats in 1980) for the highest single season batting average since 1941. Brett also recorded 118 runs batted in, while appearing in just 117 games; it was the first instance of a player averaging one RBI per game (in more than 100 games) since Walt Dropo thirty seasons prior. He led the American League in both slugging and on-base percentage.

Brett started out slowly, hitting only .259 in April. In May, he hit .329 to get his season average to .301. In June, the 27-year-old third baseman hit .472 (17–36) to raise his season average to .337, but played his last game for a month on June 10, not returning to the lineup until after the All-Star Break on July 10.

In July, after being off for a month, he played in 21 games and hit .494 (42–85), raising his season average to .390. Brett started a 30-game hitting streak on July 18, which lasted until he went 0–3 on August 19 (the following night he went 3-for-3). During those 30 games, Brett hit .467 (57–122). His high mark for the season came a week later, when Brett's batting average was at .407 on August 26, after he went 5-for-5 on a Tuesday night in Milwaukee. He batted .430 for the month of August (30 games), and his season average was at .403 with five weeks to go. For the three hot months of June, July, and August 1980, George Brett played in 60 American League games and hit .459 (111–242), most of it after a return from a monthlong injury. For these 60 games he had 69 RBIs and 14 home runs.

Brett missed another 10 days in early September and hit just .290 for the month. His average was at .400 as late as September 19, but he then had a 4 for 27 slump, and the average dipped to .384 on September 27, with a week to play. For the final week, Brett went 10-for-19, which included going 2 for 4 in the final regular season game on October 4. His season average ended up at .390 (175 hits in 449 at-bats = .389755), and he averaged more than one RBI per game.  Brett led the league in both on-base percentage (.454) and slugging percentage (.664) on his way to capturing 17 of 28 possible first-place votes in the MVP race. Since Al Simmons also batted .390 in 1931 for the Philadelphia Athletics, the only higher averages subsequent to 1931 were by Ted Williams of the Red Sox (.406 in 1941) and Tony Gwynn of the San Diego Padres (.394 in the strike-shortened 1994 season).

More importantly, the Royals won the American League West, and would face the Eastern champion Yankees in the ALCS.

1980 postseason
During the 1980 post-season, Brett led the Royals to their first American League pennant, sweeping the playoffs in three games from the rival Yankees who had beaten K.C. in the 1976, 1977 and 1978 playoffs. During Game 2 of the 1980 ALCS, Willie Randolph was on second base in the top of the eighth with two outs and the Royals up by just one run. Bob Watson hit a ball to the left field corner of Royals Stadium. The ball bounced right to Willie Wilson, but Wilson was not known for having a great arm, and third base coach Mike Ferraro waved Randolph home. Wilson overthrew U L Washington, the cut-off man, but Brett was in position behind him to catch the ball, then throw to Darrell Porter, who tagged out Randolph in a slide. TV cameras captured a furious George Steinbrenner fuming immediately after the play. The Royals won 3–2. Brett claimed after the game that he had deliberately positioned himself to cut off the throw in case Washington missed it, but Tommy John of the Yankees disagreed, thinking that if Brett had been backing up Washington, he would have been between shortstop and home plate, not over behind third base. Either way, he was in the perfect position to throw out Randolph. In Game 3, Brett hit a ball well into the third deck of Yankee Stadium off Yankees closer Goose Gossage. Gossage's previous pitch had been timed at 97 mph, leading ABC broadcaster Jim Palmer to say, "I doubt if he threw that ball 97 miles an hour."  A moment later Palmer was given the actual reading of 98. "Well, I said it wasn't 97", Palmer replied.  Brett then hit .375 in the 1980 World Series, but the Royals lost in six games to the Philadelphia Phillies. During the Series, Brett made headlines after leaving Game 2 in the 6th inning due to hemorrhoid pain. Brett had minor surgery the next day, and in Game 3 returned to hit a home run as the Royals won in 10 innings 4–3. After the game, Brett was famously quoted "...my problems are all behind me".  In 1981 he missed two weeks of spring training to have his hemorrhoids removed.

Pine Tar Incident

On July 24, 1983, with the Royals playing against the Yankees at Yankee Stadium, in the top of the ninth inning with two out, Brett hit a go-ahead two-run homer off of Goose Gossage to put the Royals up 5–4. After the home run, Yankees manager Billy Martin cited to the umpires a rule, stating that any foreign substance on a bat could extend no further than 18 inches from the knob. The umpires measured the amount of pine tar, a legal substance used by hitters to improve their grip, on Brett's bat; the pine tar extended about 24 inches. The home plate umpire, Tim McClelland, signaled Brett out, ending the game as a Yankees win. Enraged, Brett charged out of the dugout directly toward McClelland, and had to be physically restrained by two umpires and Royals manager Dick Howser.

The Royals protested the game, which was upheld by American League president Lee MacPhail, who ruled that the bat should have been excluded from future use, but the home run should not have been nullified. Amid much controversy, the game was resumed on August 18, 1983, from the point of Brett's home run, and ended with a Royals win.

1985
In 1985, Brett had another brilliant season in which he helped propel the Royals to their second American League Championship. He batted .335 with 30 home runs and 112 RBI, finishing in the top 10 of the league in 10 different offensive categories. Defensively, he won his only Gold Glove, which broke Buddy Bell's six-year run of the award, and finished second in American League MVP voting to Don Mattingly. In the final week of the regular season, he went 9-for-20 at the plate with 7 runs, 5 homers, and 9 RBI in six crucial games, five of them victories, as the Royals closed the gap and won the division title at the end. He was MVP of the 1985 playoffs against the Toronto Blue Jays, with an incredible Game 3. With KC down in the series two games to none, Brett went 4-for-4, homering in his first two at bats against Doyle Alexander, and doubled to the same spot in right field in his third at bat, leading the Royals' comeback. Brett then batted .370 in the World Series against the St. Louis Cardinals, including a four-hit performance in Game 7. The Royals again rallied from a 3–1 deficit to become World Series champions for the first time in their history.

1986–1993

In 1988, Brett moved across the diamond to first base in an effort to reduce his chances of injury and had another top-notch season with a .306 average, 24 homers and 103 RBI. But after batting just .282 with 12 homers the next year, it looked like his career might be slowing down. He got off to a terrible start in 1990 and at one point even considered retirement. But his manager, former teammate John Wathan, encouraged him to stick it out. Finally, in July, the slump ended and Brett batted .386 for the rest of the season. In September, he caught Rickey Henderson for the league lead, and in a battle down to the last day of the season, captured his third batting title with a .329 mark. This feat made Brett the only major league player to win batting titles in three different decades.

Brett played three more seasons for the Royals, mostly as their designated hitter, but occasionally filling in for injured teammates at first base. He passed the 3,000-hit mark in 1992, though he was picked off by Angels first baseman Gary Gaetti after stepping off the base to start enjoying the moment. Brett retired after the 1993 season; in his final at-bat, he hit a single up the middle against Rangers closer Tom Henke and scored on a home run by now teammate Gaetti. His last game was also notable as being the final game ever played at Arlington Stadium.

Hall of Fame

Brett was elected to the Hall of Fame in 1999, with what was then the fourth-highest voting percentage in baseball history (98.2%), trailing only Tom Seaver, Nolan Ryan, and Ty Cobb. In 2007, Cal Ripken Jr. passed Brett with 98.5% of the vote. His voting percentage was higher than all-time outfielders Babe Ruth, Hank Aaron, Willie Mays, Stan Musial, Ted Williams, and Joe DiMaggio.

Brett's No. 5 was retired by the Royals on May 14, 1994. His number was the second number retired in Royals history, preceded by former Royals manager, Dick Howser (No. 10), in 1987. It was followed by second baseman and longtime teammate Frank White's No. 20 in 1995.

He was voted the Hometown Hero for the Royals in a two-month fan vote. This was revealed on the night of September 27, 2006 in an hour-long telecast on ESPN. He was one of the few players to receive more than 400,000 votes.

Legacy

His 3,154 career hits are the most by any third baseman in major league history, and 16th all-time. Baseball historian Bill James regards him as the second-best third baseman of all time, trailing only his contemporary, Mike Schmidt. In 1999 he ranked Number 55 on The Sporting News''' list of the 100 Greatest Baseball Players, and was nominated as a finalist for the Major League Baseball All-Century Team. Brett is one of four players in MLB history to accumulate 3,000 hits, 300 home runs, and a career .300 batting average (the others are Stan Musial, Willie Mays, and Hank Aaron). Most indicative of his hitting style, Brett is sixth on the career doubles list, with 665 (trailing Tris Speaker, Pete Rose, Stan Musial, Ty Cobb, and Craig Biggio).

A photo in the July 1976 edition of National Geographic showing Brett signing baseballs for fans with his team's name emblazoned across his shirt was the inspiration for New Zealand singer-songwriter Lorde's 2013 song "Royals," which won the 2014 Grammy Award for Song of the Year.
Brett was inducted into the Missouri Sports Hall of Fame in 1994.
Brett was inducted into the Kansas Sports Hall of Fame in 2017.

The Mendoza Line

George Brett is credited with popularizing the phrase the Mendoza Line, which is used to represent a sub-.200 batting average regarded as unacceptable at the Major League level. It derives from shortstop Mario Mendoza, a career .215 hitter who finished  below .200 five times in his nine seasons in the big leagues - including at .198 the year the term is claimed to have been coined by a pair of his teammates.

Brett referred to the Mendoza Line in an interview, which was picked up by ESPN baseball anchor  Chris Berman and then expanded into the world of SportsCenter.

Post-baseball activities

Following his playing career, Brett became a vice president of the Royals and has worked as a part-time coach, as a special instructor in spring training, as an interim batting coach, and as a minor league instructor dispatched to help prospects develop. He also runs a baseball equipment and glove company named Brett Bros. with Bobby and, until his death, Ken Brett. He has also lent his name to a restaurant that failed on the Country Club Plaza.

In 1992, Brett married the former Leslie Davenport, and they reside in the Kansas City suburb of Mission Hills, Kansas. The couple has three children: Jackson (named after George's father), Dylan (named after Bob Dylan), and Robin (named after fellow Hall of Famer Robin Yount of the Milwaukee Brewers).

Brett has continued to raise money for amyotrophic lateral sclerosis (ALS), commonly known as Lou Gehrig's disease. Brett started to raise money for the Keith Worthington Chapter during his playing career in the mid-1980s.

He and his dog Charlie appeared in a PETA ad campaign, encouraging people not to leave their canine companions in the car during hot weather. He also threw out the ceremonial first pitch to Mike Napoli at the 2012 Major League Baseball All-Star Game.

On May 30, 2013, the Royals announced that Brett and Pedro Grifol would serve as batting coaches for the organization. On July 25, 2013 (the day following the 30th anniversary of the pine tar incident, the Royals announced that Brett would serve as vice president of baseball operations.

In 2015, Brett was the National Baseball Hall of Fame recipient of the Bob Feller Act of Valor Award for his support of current and former service members of the United States Military. 

Brett appeared as himself in the ABC sitcom Modern Family on March 28, 2018, alongside main cast member Eric Stonestreet, a Kansas City native and Royals fan, whose character on the show is also an avid fan.

Brett appeared as himself in the Brockmire episode "Player to Be Named Later", in which he is dating Jules (Amanda Peet), much to Brockmire's despair; in the episode "Low and Away", Jules informs Brockmire that she and her now-husband Brett are getting a divorce. Series creator Joel Church-Cooper said in a statement, "When I created a show about a fake Kansas City legend, Jim Brockmire, I thought it only appropriate to have him worship the biggest Kansas City legend of them all -- George Brett."

He is also a recurring guest on the podcast Pardon My Take'' which is presented by Barstool Sports.

Team ownership
In 1998, an investor group headed by Brett and his older brother, Bobby, made an unsuccessful bid to purchase the Kansas City Royals. Brett is the principal owner of the Tri-City Dust Devils, the Single-A affiliate of the San Diego Padres. He and his brother Bobby also co-own the Rancho Cucamonga Quakes, a Los Angeles Dodgers Single-A partner, and lead ownership groups that control the Spokane Chiefs of the Western Hockey League, the West Coast League's Bellingham Bells, and the High Desert Mavericks of the California League.

See also

 20–20–20 club
 3,000 hit club
 List of Major League Baseball players to hit for the cycle
 List of Major League Baseball annual doubles leaders
 List of Major League Baseball annual triples leaders
 List of Major League Baseball batting champions
 List of Major League Baseball career doubles leaders
 List of Major League Baseball career hits leaders
 List of Major League Baseball career home run leaders
 List of Major League Baseball career triples leaders
 List of Major League Baseball career runs batted in leaders
 List of Major League Baseball career runs scored leaders
 List of Major League Baseball career stolen bases leaders
 List of Major League Baseball career total bases leaders
 List of Major League Baseball doubles records
 List of Major League Baseball hit records
 List of Major League Baseball players who spent their entire career with one franchise

References

Further reading

External links

, or Baseball-Almanac.com

1953 births
Living people
National Baseball Hall of Fame inductees
Billings Mustangs players
San Jose Bees players
Omaha Royals players
Kansas City Royals players
Gold Glove Award winners
American League Most Valuable Player Award winners
American League All-Stars
American League batting champions
Major League Baseball broadcasters
Major League Baseball players with retired numbers
Major League Baseball designated hitters
Major League Baseball third basemen
Baseball players from California
Baseball players from West Virginia
Sportspeople from Los Angeles County, California
American League Championship Series MVPs
El Segundo High School alumni
Silver Slugger Award winners
American sportsmen
People from Glen Dale, West Virginia
People from Mission Hills, Kansas
"What Else Is There?" is the third single from the Norwegian duo Röyksopp's second album The Understanding. It features the vocals of Karin Dreijer from the Swedish electronica duo The Knife. The album was released in the UK with the help of Astralwerks.

The single was used in an O2 television advertisement in the Czech Republic and in Slovakia during 2008. It was also used in the 2006 film Cashback and the 2007 film, Meet Bill. Trentemøller's remix of "What Else is There?" was featured in an episode of the HBO show Entourage.

The song was covered by extreme metal band Enslaved as a bonus track for their album E.

The song was listed as the 375th best song of the 2000s by Pitchfork Media.

Official versions
"What Else Is There?" (Album Version) – 5:17
"What Else Is There?" (Radio Edit) – 3:38
"What Else Is There?" (Jacques Lu Cont Radio Mix) – 3:46
"What Else Is There?" (The Emperor Machine Vocal Version) – 8:03
"What Else Is There?" (The Emperor Machine Dub Version) – 7:51
"What Else Is There?" (Thin White Duke Mix) – 8:25
"What Else Is There?" (Thin White Duke Edit) – 4:50
"What Else Is There?" (Thin White Duke Remix) (Radio Edit) – 3:06
"What Else Is There?" (Trentemøller Remix) – 7:42
"What Else Is There?" (Vitalic Remix) – 5:14

Response
The single was officially released on 5 December 2005 in the UK. The single had a limited release on 21 November 2005 to promote the upcoming album. On the UK Singles Chart, it peaked at number 32, while on the UK Dance Chart, it reached number one.

Music video
The music video was directed by Martin de Thurah. It features Norwegian model Marianne Schröder who is shown lip-syncing Dreijer's voice. Schröder is depicted as a floating woman traveling across stormy landscapes and within empty houses. Dreijer makes a cameo appearance as a woman wearing an Elizabethan ruff while dining alone at a festive table.

Movie spots

The song is also featured in the movie Meet Bill as characters played by Jessica Alba and Aaron Eckhart smoke marijuana while listening to it. It is also part of the end credits music of the film Cashback.

Charts

References

2005 singles
Röyksopp songs
Astralwerks singles
Songs written by Svein Berge
Songs written by Torbjørn Brundtland
2004 songs
Songs written by Roger Greenaway
Songs written by Olof Dreijer
Songs written by Karin Dreijer In computer programming,  is a ternary operator that is part of the syntax for basic conditional expressions in several programming languages. It is commonly referred to as the conditional operator, inline if (iif), or ternary if. An expression  evaluates to  if the value of  is true, and otherwise to . One can read it aloud as "if a then b otherwise c".

It originally comes from CPL, in which equivalent syntax for e1 ? e2 : e3 was e1 → e2, e3.

Although many ternary operators are possible, the conditional operator is so common, and other ternary operators so rare, that the conditional operator is commonly referred to as the ternary operator.

Variations
The detailed semantics of "the" ternary operator as well as its syntax differs significantly from language to language.

A top level distinction from one language to another is whether the expressions permit side effects (as in most procedural languages) and whether the language provides short-circuit evaluation semantics, whereby only the selected expression is evaluated (most standard operators in most languages evaluate all arguments).

If the language supports expressions with side effects but does not specify short-circuit evaluation, then a further distinction exists about which expression evaluates first—if the language guarantees any specific order (bear in mind that the conditional also counts as an expression).

Furthermore, if no order is guaranteed, a distinction exists about whether the result is then classified as indeterminate (the value obtained from some order) or undefined (any value at all at the whim of the compiler in the face of side effects, or even a crash).

If the language does not permit side-effects in expressions (common in functional languages), then the order of evaluation has no value semantics—though it may yet bear on whether an infinite recursion terminates, or have other performance implications (in a functional language with match expressions, short-circuit evaluation is inherent, and natural uses for the ternary operator arise less often, so this point is of limited concern).

For these reasons, in some languages the statement form  can have subtly different semantics than the block conditional form } (in the C language—the syntax of the example given—these are in fact equivalent).

The associativity of nested ternary operators can also differ from language to language. In almost all languages, the ternary operator is right associative so that  evaluates intuitively as , but PHP in particular is notoriously left-associative, and evaluates as follows: , which is rarely what any programmer expects. (The given examples assume that the ternary operator has low operator precedence, which is true in all C-family languages, and many others.)

Equivalence to map
The ternary operator can also be viewed as a binary map operation.

In R—and other languages with literal expression tuples—one can simulate the ternary operator with something like the R expression  (this idiom is slightly more natural in languages with 0-origin subscripts).

However, in this idiom it is almost certain that the entire tuple expression will evaluate prior to the subscript expression, so there will be no short-circuit semantics.

Nested ternaries can be simulated as  where the function  returns the index of the first true value in the condition vector. Note that both of these map equivalents are binary operators, revealing that the ternary operator is ternary in syntax, rather than semantics. These constructions can be regarded as a weak form of currying based on data concatenation rather than function composition.

If the language provides a mechanism of futures or promises, then short-circuit evaluation can sometimes also be simulated in the context of a binary map operation.

Conditional assignment
 is used as follows:

 condition ? value_if_true : value_if_false

The condition is evaluated true or false as a Boolean expression. On the basis of the evaluation of the Boolean condition, the entire expression returns value_if_true if condition is true, but value_if_false otherwise. Usually the two sub-expressions value_if_true and value_if_false must have the same type, which determines the type of the whole expression. The importance of this type-checking lies in the operator's most common use—in conditional assignment statements. In this usage it appears as an expression on the right side of an assignment statement, as follows:

 variable = condition ? value_if_true : value_if_false

The ?: operator is similar to the way conditional expressions (if-then-else constructs) work in functional programming languages, like Scheme, ML, and Haskell, since if-then-else forms an expression instead of a statement in those languages.

Usage
The conditional operator's most common usage is to make a terse simple conditional assignment statement. For example, if we wish to implement some C code to change a shop's normal opening hours from 9 o'clock to 12 o'clock on Sundays, we may use

int opening_time = (day == SUNDAY) ? 12 : 9;

instead of the more verbose

int opening_time;

if (day == SUNDAY)
    opening_time = 12;
else
    opening_time = 9;

The two forms are nearly equivalent. Keep in mind that the  is an expression and if-then-else is a statement. Note that neither the true nor false portions can be omitted from the conditional operator without an error report upon parsing. This contrasts with if-then-else statements, where the else clause can be omitted.

Most of the languages emphasizing functional programming don't need such an operator as their regular conditional expression(s) is an expression in the first place e.g. the Scheme expression  is equivalent in semantics to the C expression . This is also the case in many imperative languages, starting with ALGOL where it is possible to write , or Smalltalk () or Ruby (, although  works as well).

Note that some languages may evaluate both the true- and false-expressions, even though only one or the other will be assigned to the variable. This means that if the true- or false-expression contain a function call, that function may be called and executed (causing any related side-effects due to the function's execution), regardless of whether or not its result will be used. Programmers should consult their programming language specifications or test the ternary operator to determine whether or not the language will evaluate both expressions in this way. If it does, and this is not the desired behaviour, then an if-then-else statement should be used.

ActionScript 3
condition ? value_if_true : value_if_false

Ada
The 2012 edition of Ada has introduced conditional expressions (using  and ), as part of an enlarged set of expressions including quantified expressions and expression functions. The Rationale for Ada 2012 states motives for Ada not having had them before, as well as motives for now adding them, such as to support "contracts" (also new).

Pay_per_Hour := (if Day = Sunday
   then 12.50
   else 10.00);

When the value of an if_expression is itself of Boolean type, then the  part may be omitted, the value being True. Multiple conditions may chained using .

ALGOL 68
Both ALGOL 68's choice clauses (if and the case clauses) provide the coder with a choice of either the "bold" syntax or the "brief" form.

 Single if choice clause:
 if condition then statements [ else statements ] fi
 "brief" form:  ( condition | statements | statements )

 Chained if choice clause:
 if condition1 then statements elif condition2 then statements [ else statements ] fi
 "brief" form:  ( condition1 | statements |: condition2 | statements | statements )

APL
With the following syntax, both expressions are evaluated (with  evaluated first, then , then ):

result ← value_if_true ⊣⍣ condition ⊢ value_if_false

This alternative syntax provides short-circuit evaluation:

result ← { condition : expression_if_true ⋄ expression_if_false } ⍬

AWK
result = condition ? value_if_true : value_if_false

Bash
A true ternary operator only exists for arithmetic expressions:

((result = condition ? value_if_true : value_if_false))

For strings there only exist workarounds, like e.g.:

result=$([[ "$a" = "$b" ]] && echo "value_if_true" || echo "value_if_false")

Where  can be any condition  construct can evaluate. Instead of the  there can be any other bash command. When it exits with success, the first echo command is executed, otherwise the second one is executed.

C
A traditional if-else construct in C, Java and JavaScript is written:

if (a > b) {
    result = x;
}
else {
    result = y;
}

This can be rewritten as the following statement:

result = a > b ? x : y;

As in the if-else construct only one of the expressions 'x' and 'y' is evaluated. This is significant if the evaluation of 'x' or 'y' has side effects. The behaviour is undefined if an attempt is made to use the result of the conditional operator as an lvalue.

A GNU extension to C allows omitting the second operand, and using implicitly the first operand as the second also:

a == x ? : y;

The expression is equivalent to

a == x ? (a == x) : y;

except that if x is an expression, it is evaluated only once. The difference is significant if evaluating the expression has side effects. This shorthand form is sometimes known as the Elvis operator in other languages.

C#
In C#, if condition is true, first expression is evaluated and becomes the result; if false, the second expression is evaluated and becomes the result. As with Java only one of two expressions is ever evaluated.

// condition ? first_expression : second_expression;

static double sinc(double x) 
{
     return x != 0.0 ? Math.Sin(x) / x : 1.0;
}

C++
Unlike in C, the precedence of the  operator in C++ is the same as that of the assignment operator ( or ), and it can return an lvalue. This means that expressions like  and  are both legal and are parsed differently, the former being equivalent to .

In C++ there are conditional assignment situations where use of the if-else statement is impossible, since this language explicitly distinguishes between initialization and assignment. In such case it is always possible to use a function call, but this can be cumbersome and inelegant. For example, to pass conditionally different values as an argument for a constructor of a field or a base class, it is impossible to use a plain if-else statement; in this case we can use a conditional assignment expression, or a function call. Bear in mind also that some types allow initialization, but do not allow assignment, or even that the assignment operator and the constructor do totally different things. This last is true for reference types, for example:

#include <iostream>
#include <fstream>
#include <string>

int main(int argc, char *argv[])
{
    std::string name;
    std::ofstream fout;

    if (argc > 1 && argv[1])
    {
        name = argv[1];
        fout.open(name.c_str(), std::ios::out | std::ios::app);
    }

    std::ostream &sout = name.empty() ? std::cout : fout;

    sout << "Hello, world!\n";

    return 0;
}

In this case there is no possibility of using an if-else statement in place of the  operator (Although we can replace the use of  with a function call, inside of which can be an if-else statement).

Furthermore, the conditional operator can yield an lvalue, i.e. a value to which another value can be assigned. Consider the following example:

#include <iostream>

int main(int argc, char *argv[]) 
{
    int a = 0;
    int b = 0;

    (argc > 1 ? a : b) = 1;

    std::cout << "a: " << a
              << " b: " << b
              << '\n';

    return 0;
}

In this example, if the boolean expression  yields the value  on line 8, the value  is assigned to the variable , otherwise the value  is assigned to the variable .

In C++ and other various languages, ternary operators like  are also possible but are very rare.

CFML
Example of the  operator in CFML:

result = randRange(0,1) ? "heads" : "tails";

Roughly 50% of the time the  expression will return 1 (true) or 0 (false); meaning result will take the value "heads" or "tails" respectively.

Lucee, Railo, and ColdFusion 11-specific
Lucee, Railo, and ColdFusion 11 also implement the Elvis operator,  which will return the value of the expression if it is not-null, otherwise the specified default.

Syntax:

result = expression ?: value_if_expression_is_null

Example:

result = f() ?: "default";

// where...
function f(){
    if (randRange(0,1)){ // either 0 or 1 (false / true)
        return "value";
    }
}

writeOutput(result);

The function  will return  roughly 50% of the time, otherwise will not return anything. If  returns "value",  will take that value, otherwise will take the value "default".

CoffeeScript
Example of using this operator in CoffeeScript:

if 1 is 2 then "true value" else "false value"

Returns "false value".

Common Lisp
Assignment using a conditional expression in Common Lisp:

(setf result (if (> a b) x y))

Alternative form:

(if (> a b)
  (setf result x)
  (setf result y))

Crystal
Example of using this operator in Crystal:

1 == 2 ? "true value" : "false value"

Returns .

The Crystal compiler transforms conditional operators to  expressions, so the above is semantically identical to:

if 1 == 2
  "true value"
else
  "false value"
end

Dart
The Dart programming language's syntax belongs to the C family, primarily inspired by languages like Java, C# and JavaScript, which means it has inherited the traditional  syntax for its conditional expression.

Example:

return x.isEven ? x ~/ 2 : x * 3 + 1;

Like other conditions in Dart, the expression before the  must evaluate to a Boolean value.

The Dart syntax uses both  and  in various other ways, which causes ambiguities in the language grammar. An expression like:

{ x as T ? [1] : [2] }

could be parsed as either a "set literal" containing one of two lists or as a "map literal" {((x as T?)[1]) : [2]}. The language always chooses the conditional expression in such situations.

Dart also has a second ternary operator, the  operator commonly used for setting values in lists or maps, which makes the term "the ternary operator" ambiguous in a Dart context.

Delphi
In Delphi the  function can be used to achieve the same as . If the  library is used, the  function returns a numeric value such as an Integer, Double or Extended. If the  library is used, this function can also return a string value.

Using 

function IfThen(AValue: Boolean; const ATrue: Integer; const AFalse: Integer): Integer;
function IfThen(AValue: Boolean; const ATrue: Int64; const AFalse: Int64): Int64;
function IfThen(AValue: Boolean; const ATrue: UInt64; const AFalse: UInt64): UInt64;
function IfThen(AValue: Boolean; const ATrue: Single; const AFalse: Single): Single;
function IfThen(AValue: Boolean; const ATrue: Double; const AFalse: Double): Double;
function IfThen(AValue: Boolean; const ATrue: Extended; const AFalse: Extended): Extended;

Using the  library

function IfThen(AValue: Boolean; const ATrue: string; AFalse: string = ''): string;

Usage example:

function GetOpeningTime(Weekday: Integer): Integer;
begin
  { This function will return the opening time for the given weekday: 12 for Sundays, 9 for other days }
  Result := IfThen((Weekday = 1) or (Weekday = 7), 12, 9);
end;

Unlike a true ternary operator however, both of the results are evaluated prior to performing the comparison. For example, if one of the results is a call to a function which inserts a row into a database table, that function will be called whether or not the condition to return that specific result is met.

F#

In F# the built-in syntax for if-then-else is already an expression that always must return a value.

let num = if x = 10 then 42 else 24

F# has a special case where you can omit the else branch if the return value is of type unit. This way you can do side-effects, without using a else branch.

if x = 10 then
    printfn "It is 10"

But even in this case, the if expression would return unit. You don't need to write the else branch, because the compiler will assume the unit type on else.

FORTH
Since FORTH is a stack-oriented language, and any expression can leave a value on the stack, all // sequences can generate values:

: test ( n -- n )  1 AND  IF 22 ELSE 42 THEN ;

This word takes 1 parameter on the stack, and if that number is odd, leaves 22. If it's even, 42 is left on the stack.

Fortran
With the additions to the code in the 1995 release, the ternary operator was added to the Fortran compiler as the intrinsic function :

variable = merge(x,y,a>b)

Note that both x and y are evaluated before the results of one or the other are returned from the function. Here, x is returned if the condition holds true and y otherwise.

FreeMarker 
This built-in exists since FreeMarker 2.3.20.

Used like booleanExp?then(whenTrue, whenFalse), fills the same role as the ternary operator in C-like languages.

<#assign x = 10>
<#assign y = 20>
<#-- Prints the maximum of x and y: -->
${(x > y)?then(x, y)}

Go
There is no ternary if in Go, so use of the full if statement is always required.

Haskell
The built-in if-then-else syntax is inline: the expression

if predicate then expr1 else expr2

has type

Bool -> a -> a -> a

The base library also provides the function :

bool :: a -> a -> Bool -> a

In both cases, no special treatment is needed to ensure that only the selected expression is evaluated, since Haskell is non-strict by default. This also means an operator can be defined that, when used in combination with the  operator, functions exactly like  in most languages:

(?) :: Bool -> a -> a -> a
(?) pred x y = if pred then x else y
infix 1 ?

-- example (vehicle will evaluate to "airplane"):
arg = 'A'
vehicle = arg == 'B' ? "boat" $
          arg == 'A' ? "airplane" $
          arg == 'T' ? "train" $
                       "car"

However, it is more idiomatic to use pattern guards

-- example (vehicle will evaluate to "airplane"):
arg = 'A'
vehicle | arg == 'B' = "boat"
        | arg == 'A' = "airplane"
        | arg == 'T' = "train"
        | otherwise  = "car"

Java
In Java this expression evaluates to:

// If foo is selected, assign selected foo to bar. If not, assign baz to bar.
Object bar = foo.isSelected() ? foo : baz; 

Note that Java, in a manner similar to C#, only evaluates the used expression and will not evaluate the unused expression.

Julia
In Julia, "Note that the spaces around  and  are mandatory: an expression like  is not a valid ternary expression (but a newline is acceptable after both the  and the )."

JavaScript
The conditional operator in JavaScript is similar to that of C++ and Java, except for the fact the middle expression cannot be a comma expression. Also, as in C++, but unlike in C or Perl, it will not bind tighter than an assignment to its right— is equivalent to  instead of .

var timeout = settings !== null ? settings.timeout : 1000;

Just like C# and Java, the expression will only be evaluated if, and only if, the expression is the matching one for the condition given; the other expression will not be evaluated.

Kotlin 
Kotlin does not include the traditional  ternary operator, however, s can be used as expressions that can be assigned, achieving the same results. Note that, as the complexity of your conditional statement grows, you might consider replacing your - expression with a  expression.

val max = if (a > b) a else b

Lua 
Lua does not have a traditional conditional operator. However, the short-circuiting behaviour of its  and  operators allows the emulation of this behaviour:

-- equivalent to var = cond ? a : b;
var = cond and a or b

This will succeed unless  is logically false (i.e.  or ); in this case, the expression will always result in . This can result in some surprising behaviour if ignored.

SQL
The SQL  expression is a generalization of the ternary operator. Instead of one conditional and two results, n conditionals and n+1 results can be specified.

With one conditional it is equivalent (although more verbose) to the ternary operator:

SELECT (CASE WHEN a > b THEN x ELSE y END) AS CONDITIONAL_EXAMPLE
  FROM tab;

This can be expanded to several conditionals:

SELECT (CASE WHEN a > b THEN x WHEN a < b THEN y ELSE z END) AS CONDITIONAL_EXAMPLE
  FROM tab;

MySQL
In addition to the standard  expression, MySQL provides an  function as an extension:

IF(cond, a, b);

SQL Server
In addition to the standard  expression, SQL Server (from 2012) provides an  function:

IIF(condition, true_value, false_value)

Oracle SQL
In addition to the standard  expression, Oracle has a variadic functional counterpart which operates similarly to a switch statement and can be used to emulate the conditional operator when testing for equality.

-- General syntax takes case-result pairs, comparing against an expression, followed by a fall-back result:
DECODE(expression, case1, result1,
                   ...
                   caseN, resultN,
                          resultElse)

-- We can emulate the conditional operator by just selecting one case:
DECODE(expression, condition, true, false)

The  function is, today, deprecated in favour of the standard  expression. This can be used in both Oracle SQL queries as well as PL/SQL blocks, whereas  can only be used in the former.

Perl
A traditional if-else construct in Perl is written:

if ($a > $b) {
    $result = $x;
} else {
    $result = $y;
}

Rewritten to use the conditional operator:

$result = $a > $b ? $x : $y;

The precedence of the conditional operator in perl is the same as in C, not as in C++. This is conveniently of higher precedence than a comma operator but lower than the precedence of most operators used in expressions within the ternary operator, so the use of parentheses is rarely required.

Its associativity matches that of C and C++, not that of PHP. Unlike C but like C++, perl allows the use of the conditional expression as an L-value; for example:

$a > $b ? $x : $y = $result;

will assign  to either  or  depending on the logical expression's boolean result.

The respective precedence rules and associativities of the operators used guarantee that the version absent any parentheses is equivalent to this explicitly parenthesized version:

(($a > $b) ? $x : $y) = $result;

This is equivalent to the if-else version:

if ($a > $b) {
    $x = $result;
} else {
    $y = $result;
}

PHP
A simple PHP implementation is this:

$abs = $value >= 0 ? $value : -$value;

Due to an unfortunate design of the language grammar, the conditional operator in PHP is left associative in contrast to other languages, thus given a value of T for arg, the PHP code in the following example would yield the value horse instead of train as one might expect:

<?php
$arg = "T";
$vehicle = ( ( $arg == 'B' ) ? 'bus' : 
             ( $arg == 'A' ) ? 'airplane' : 
             ( $arg == 'T' ) ? 'train' : 
             ( $arg == 'C' ) ? 'car' : 
             ( $arg == 'H' ) ? 'horse' : 
                               'feet' );
echo $vehicle;

The reason is that nesting two conditional operators produces an oversized condition with the last two options as its branches:  is really . This is acknowledged and will probably not change. To avoid this, nested parenthesis are needed, as in this example:

<?php
$arg = "T";
$vehicle = $arg == "B" ? "bus" :
          ($arg == "A" ? "airplane" :
          ($arg == "T" ? "train" :
          ($arg == "C" ? "car" :
          ($arg == "H" ? "horse" :
                         "feet"))));
echo $vehicle;

This will produce the result of train being printed to the output, analogous to a right associative conditional operator.

PHP 5.3

Since PHP 5.3 there is a shorthand of the conditional operator, sometimes referred to as the "Elvis Operator". The syntax for this shorthand is below:

$c = $a ?: $b; // equivalent to $c = $a ? $a : $b;

Python
Though it had been delayed for several years by disagreements over syntax, an operator for a conditional expression in Python was approved as Python Enhancement Proposal 308 and was added to the 2.5 release in September 2006. Python's conditional operator differs from the common  operator in the order of its operands. The general form is:

result = x if a > b else y

This form invites considering  as the normal value and  as an exceptional case. 

Prior to Python 2.5 there were a number of ways to approximate a conditional operator (for example by indexing into a two element array), all of which have drawbacks as compared to the built-in operator.

R
The traditional if-else construct in R (which is an implementation of S) is:

if (a < b) {
  x <- "true"
} else {
  x <- "false"
}

If there is only one statement in each block, braces can be omitted, like in C:

if (a < b)
  x <- "true"
else
  x <- "false"

The code above can be written in the following non-standard condensed way:

x <- if (a < b) "true" else "false"

There exists also the function  that allows rewriting the expression above as:

x <- ifelse(a < b, "true", "false")

The  function is automatically vectorized. For instance:

> ifelse(c (0, 2) < 1, "true", "false")
[1] "true"  "false"

Raku
Raku uses a doubled  symbol instead of single 
and a doubled  symbol instead of 

$result = $a > $b ?? $x !! $y;

Ruby
Example of using this operator in Ruby:

1 == 2 ? "true value" : "false value"

Returns "false value".

A traditional if-else construct in Ruby is written:

if a > b
  result = x
else
  result = y
end

This could also be written as:

result = if a > b
  x
else
  y
end

These can be rewritten as the following statement:

result = a > b ? x : y

Rust
Being an expression-oriented programming language, Rust's existing if expr1 else expr2 syntax can behave as the traditional  ternary operator does. Earlier versions of the language did have the  operator but it was removed due to duplication with .

Note the lack of semi-colons in the code below compared to a more declarative ... block, and the semi-colon at the end of the assignment to .

let x = 5;

let y = if x == 5 {
    10
} else {
    15
};

This could also be written as:

let y = if x == 5 { 10 } else { 15 };

Note that curly braces are mandatory in Rust conditional expressions.

You could also use a  expression:

let y = match x {
    5 => 10,
    _ => 15,
};

Scheme
Same as in Common Lisp. Every expression has a value. Thus the builtin  can be used:

(let* ((x 5)
       (y (if (= x 5) 10 15)))
  ...)

Smalltalk
Every expression (message send) has a value. Thus  can be used:

|x y|

x := 5.
y := (x == 5) ifTrue:[10] ifFalse:[15].

Swift
The ternary conditional operator of Swift is written in the usual way of the C tradition, and is used within expressions.

let result = a > b ? a : b

Tcl
In Tcl, this operator is available in expr expressions only:

set x 5
set y [expr {$x == 5 ? 10 : 15}]

Outside of expr, if can be used for a similar purpose, as it also returns a value:
package require math

set x 5
set y [if {$x == 5} {
    ::math::random $x
} else {
    ::math::fibonacci $x
}]

TestStand
In a National Instruments TestStand expression, if condition is true, the first expression is evaluated and becomes the output of the conditional operation; if false, the second expression is evaluated and becomes the result. Only one of two expressions is ever evaluated.

condition ? first_expression : second_expression

For example:

RunState.Root.Parameters.TestSocket.Index == 3 ? Locals.UUTIndex = 3 : Locals.UUTIndex = 0

Sets the  local variable to 3 if  is 3, otherwise it sets  to 0.

Similar to other languages, first_expression and second_expression do not need to be autonomous expressions, allowing the operator to be used for variable assignment:

Locals.UUTIndex = ( RunState.Root.Parameters.TestSocket.Index == 3 ? 3 : 0 )

Verilog
Verilog is technically a hardware description language, not a programming language though the semantics of both are very similar. It uses the  syntax for the ternary operator.

// using blocking assignment
wire out;
assign out = sel ? a : b;

This is equivalent to the more verbose Verilog code:

// using blocking assignment
wire out;
if (sel === 1)  // sel is 1, not 0, x or z
    assign out = a;
else if (sel === 0)  // sel is 0, x or z (1 checked above)
    assign out = b;
else  // sel is x or z (0 and 1 checked above)
    assign out = [comment];  // a and b are compared bit by bit, and return for each bit
                             // an x if bits are different, and the bit value if the same

Visual Basic
Visual Basic doesn't use  per se, but has a very similar implementation of this shorthand  statement. Using the first example provided in this article, it can do:

' variable = IIf(condition, value_if_true, value_if_false)
Dim opening_time As Integer = IIf((day = SUNDAY), 12, 9)

In the above example,  is a ternary function, but not a ternary operator. As a function, the values of all three portions are evaluated before the function call occurs. This imposed limitations, and in Visual Basic .Net 9.0, released with Visual Studio 2008, an actual conditional operator was introduced, using the  keyword instead of . This allows the following example code to work:

Dim name As String = If(person Is Nothing, "", person.Name)

Using ,  would be evaluated even if person is  (Nothing), causing an exception. With a true short-circuiting conditional operator,  is not evaluated unless person is not .

Visual Basic Version 9 has added the operator  in addition to the existing  function that existed previously. As a true operator, it does not have the side effects and potential inefficiencies of the  function.

The syntaxes of the tokens are similar:  vs . As mentioned above, the function call has significant disadvantages, because the sub-expressions must all be evaluated, according to Visual Basic's evaluation strategy for function calls and the result will always be of type variant (VB) or object (VB.NET). The operator however does not suffer from these problems as it supports conditional evaluation and determines the type of the expression based on the types of its operands.

Result type
Clearly the type of the result of the  operator must be in some sense the type unification of the types of its second and third operands. In C this is accomplished for numeric types by arithmetic promotion; since C does not have a type hierarchy for pointer types, pointer operands may only be used if they are of the same type (ignoring type qualifiers) or one is void or NULL. It is undefined behaviour to mix pointer and integral or incompatible pointer types; thus

number = spell_out_numbers ? "forty-two" : 42;

will result in a compile-time error in most compilers.

?: in style guidelines
Conditional operators are widely used and can be useful in certain circumstances to avoid the use of an  statement, either because the extra verbiage would be too lengthy or because the syntactic context does not permit a statement. For example:

 #define MAX(a, b) (((a)>(b)) ? (a) : (b))

or

 for (i = 0; i < MAX_PATTERNS; i++)
    c_patterns[i].ShowWindow(m_data.fOn[i] ? SW_SHOW : SW_HIDE);

(The latter example uses the Microsoft Foundation Classes Framework for Win32.)

Initialization
An important use of the conditional operator is in allowing a single initialization statement, rather than multiple initialization statements. In many cases this also allows single assignment and for an identifier to be a constant.

The simplest benefit is avoiding duplicating the variable name, as in Python:

x = 'foo' if b else 'bar'

instead of:

if b:
    x = 'foo'
else:
    x = 'bar'

More importantly, in languages with block scope, such as C++, the blocks of an if/else statement create new scopes, and thus variables must be declared before the if/else statement, as:

std::string s;
if (b)
    s = "foo";
else
    s = "bar";

Use of the conditional operator simplifies this:

std::string s = b ? "foo" : "bar";

Furthermore, since initialization is now part of the declaration, rather than a separate statement, the identifier can be a constant (formally, of  type):

const std::string s = b ? "foo" : "bar";

Case selectors
When properly formatted, the conditional operator can be used to write simple and coherent case selectors. For example:

vehicle = arg == 'B' ? bus :
          arg == 'A' ? airplane :
          arg == 'T' ? train :
          arg == 'C' ? car :
          arg == 'H' ? horse :
                       feet;

Appropriate use of the conditional operator in a variable assignment context reduces the probability of a bug from a faulty assignment as the assigned variable is stated just once as opposed to multiple times.

Programming languages without the conditional operator
The following are examples of notable general-purpose programming languages that don't provide a conditional operator:

 CoffeeScript
 Go programming language
 MATLAB
 Pascal although Object Pascal / Delphi do have a function  to do the same (with caveats)
 Rust The  construct is an expression and can be used to get the same functionality.
 
 PowerShell (in old versions) an elegant workaround is to use (<value for true>,<value for false>)[!(<condition>)]

See also
 IIf, inline if function
 Null coalescing operator,  operator
 Elvis operator, , or sometimes , as a shorthand binary operator
 Conditioned disjunction, equivalent ternary logical connective.

References

External links
 Description of If operator in Visual Basic
 Description of Conditional Expression in Python (PEP 308)
 Description in the Java Language Specification
 Description in the PHP Language Documentation

Conditional constructs
Operators (programming)
Ternary operations
Articles with example code

de:Bedingte Anweisung und Verzweigung#Auswahloperator