• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

very weird results from ternary operator...

 
Vinnie Jenks
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a ternary comparison that returns false no matter what I provide it and it makes absolutely no sense!

My code:



While debugging, "props.getProperty("is_locally_connected")" returns "true" (string, not boolean) yet isLocal always returns false once the code runs!

Am I loosing my mind? I've gotta be missing something from 24 straight hours of coding...I need someone to point out my stupidity here even though I've written these types of statements at least a billion times...

Thanks!
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or this:
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is not with the ternary operator but with your understanding of what the == operator does.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic