The Artima Developer Community
Sponsored Link

Java Buzz Forum
No more troubles with ternary

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
No more troubles with ternary Posted: Aug 13, 2004 8:29 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: No more troubles with ternary
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement
I am a fan of the ternary operator. I get bored of if(), and prefer to jump into a ? : if it makes sense. I think part of the reason that I like it, is that I like the shortcuts in life. I really used to enjoy: my $foo = $bar || "In case"; die "Naughty" unless $you_were_good; One of the things that bugged me about the ternary operator in Java, was that it would catch some people out on items such as: String str ="whee"; StringBuilder builder = "whee"; boolean mutable = true; CharSequence chars = mutable ? builder : str; This used to fail all the time, even though both String and StringBuilder (and StringBuffer) implement CharSequence. Luckily, this now works in JDK 1.5, and we don't have to resort to the ugly: CharSequence chars = mutable ? (CharSequence)builder : (CharSequence)str;

Read: No more troubles with ternary

Topic: J2EE - Best practices for developing a robust architecture Previous Topic   Next Topic Topic: Great Interview Question - Part I

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use