Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: redefine and kill in for loops
PostPosted: Thu Oct 10, 2013 12:41 pm 
Consider a list l of rings or other objects.

Code:
...
def S;
int pos;
for (pos=1; pos<=size(l); pos++)
{
  s=l[pos];
}


Is it necessary to kill and redefine S in each loop step?


Report this post
Top
  
Reply with quote  
 Post subject: Re: redefine and kill in for loops
PostPosted: Fri Oct 11, 2013 11:38 am 

Joined: Wed May 25, 2005 4:16 pm
Posts: 275
If you want to assign l[pos] to s then the types must allow this.
For example, if s is of type int and l[pos] is of type string,
the assignment is not possible.
But if s will destroyed first and redefined as of type def
the assignment works and the type of s (which started as type def)
changes to string.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

It is currently Fri May 13, 2022 11:06 am
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group