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

Question regarding println statement  RSS feed

 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Why does the first println statement in the following code works and the other does not? Is it because in the first println statement, 12 is actually converted to a string? and in the second println statament, bye is considered as some variable that has not been initialized something? please explain.



Thanks.
 
Campbell Ritchie
Marshal
Posts: 55670
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, because you haven't declared or initialised "bye." Actually the 2nd println statement won't compile, it would work if bye existed.
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
Campbell Ritchie
Marshal
Posts: 55670
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!