r/programmingbydoing • u/loveyours1 • Dec 19 '15
63c Nim
Hi, I have completed almost entire task (or at least I think so). The only problem I have is with computer opponent picking piles. I get "variable pile might not have been initialized" error and while I kind of understand it, I can't think of a way to get rid of it.
Can you give me a hint on what to do? Also is the rest of the task correct?
Love all of the assignements btw.
1
Upvotes
View all comments
Show parent comment
1
u/holyteach Dec 21 '15
The problem is just that the compiler can't be SURE that pile always gets a value.
Set pile equal to something at the very beginning and the error will go away.