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

for(...) not working right  RSS feed

 
David Crossett
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why isn't this working? I need to go through each variable and set it by hand...meaning that I'm expecting this inputDialog to pop up 20 times...however, I'm only getting through the first loop. I can only enter values for salesperson # 0. Any ideas?
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
David Crossett
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! Duh!
 
Bill Raterink
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe, please allow me to question your answer. I usually read every Beginner post, & it's been quite an effective training tool, but your "one line answer" to this question is the SAME line he has in his code.

He seems to get it(ref. the "DUH!), but I'm not sure I do.
Is the problem here that he tests i, but increments j ?
Thanks, -Bill.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think he was pointing out the "i < ..." which should be "j < ...".
 
Bill Raterink
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ouch! I almost broke my arm.....patting myself on the back. HA!HA! I was hoping THAT was the "cure". Hey, at this rate, I'll make that intermediate level in no time. Thanks again, guys. -Bill.
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bill Raterink:
Joe, please allow me to question your answer. I usually read every Beginner post, & it's been quite an effective training tool, but your "one line answer" to this question is the SAME line he has in his code.

I try to make it easier on the folks who are learning, but not too easy (i.e. narrowing down the problem to one line but NOT pointing out the problem). The beginner gets the satisfaction of solving a problem (that "AH-HA!" moment), builds an association between the symptoms of a problem and their solution and gives them self-confidence that they CAN solve their own problems (so they aren't stuck in this forum forever).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!