This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

K&B doubt - p371, question about assumption remark  RSS feed

 
Ronald Schild
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy,

I was wondering if the comment "x must be 2" was intended to be a wrong assumption or not, in:



on page 371 in K&B (as x being say, 3, and y being false reaches it). I would have understood it if a later example would have used the snippet with a real assertion ( assert( x == 2) ; ) to prove that the assumption was wrong. But it doesn't, and the example seems to illustrate solely that sometimes we are used to put assumptions in comments.

Just checking, sorry for horrible nitpicking.
[ July 08, 2008: Message edited by: Ronald Schild ]
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice catch
I think the comment merely intends to illustrate that assumptions can be added to the source code in the form of debug comments.
Of course, as you said, the assumption is faulty in this case - and I can't imagine it was meant to be. Seeing as the text following the code snippet never refers back to it in trying to prove the debug comment wrong using the assertion mechanism.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!