Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on format

 
Tayitu Betule
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is the following code prints "true false" and not "false false"?



Thank you all.
 
Kaspar Christenson
Greenhorn
Posts: 21
Mac Scala VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Formatter %b conversion documentation states
If the argument arg is null, then the result is "false". If arg is a boolean or Boolean, then the result is the string returned by String.valueOf(). Otherwise, the result is "true".


Since you're formatting a String the result is "true".
 
Tayitu Betule
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Kaspar. That was an oversight on my side.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic