• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with = integer in a for loop  RSS feed

 
jarco voorhees
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all

What am I doing wrong here?

i try to do this:

But it keeps trowing out errors.
When I use

it compiles but the for loop will never be used.
The only workaround I found is doing this

but that is not the best way to do it I assume.

I really wan't to understand this issue.

Kind regards
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jarco voorhees wrote:

but that is not the best way to do it I assume.
I really wan't to understand this issue.

Kind regards


The syntax would be- for(initialisation;condition;increment){}

In the first case you are doing an assignment when a condition is required, so it doesnt compile.

In the other two cases- It depends on what the value of getal is. It might have been 0. There's is not best way in terms of using for-loop. It all depends on how its going to work in your code situation.

Edit: ==- will not work as it will not evaluate the condition. ==- will be false and hence will not evaluate the loop body.
 
jarco voorhees
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will paste the complete code because I want to get to the bottom of this now.




 
jarco voorhees
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I think I solved it myself.
I forgot to think about the fact that the number will not always be Equal to the value of waarde. It will work with >= .
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jarco voorhees wrote:Sorry I think I solved it myself.
I forgot to think about the fact that the number will not always be Equal to the value of waarde. It will work with >= .


Yeah, you are right. Just edited my reply.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!