• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

? ... : operator

 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it frowned upon to use this operator for variable assignment? I've been looking through my 4b code, and have noticed several if/else statements that I use solely for the purpose of setting a String, and thought I could reduce the code a bit by using ?: instead of the whole if/else statement. While it compacts the code, I'm not sure if it is viewed as being less readable.
Thanks!
Jason
[This message has been edited by jason adam (edited June 01, 2001).]
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use of the ? ... : operator is acceptable.
 
Daniel Olson
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are interested here is a thread where we discussed using the ternary operator.
http://www.javaranch.com/ubb/Forum19/HTML/000179.html
[ February 06, 2003: Message edited by: Marilyn de Queiroz ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic