Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting compiler to ignore errors  RSS feed

 
S Gregg
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I am having a simple issue which I think is just my compiler being stubborn, I am using a switch statement and creating a different object based on which case is run. My problem is the compiler gives an error because I am using the same variable name in all 5 cases. Is there any workaround to this, I know how I can work around it by changing the variable name in each case but I am trying to keep my program as simple as i can. Thanks for your help


 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


and as a general note, "obj" is a horrible name for a variable, since EVERYTHING (almost) in java is a object.
 
S Gregg
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Fred, should have figured that one, initialize the object first, guess it was late.

Point taken on the naming of my variable, I renamed it to polyhedron.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!