YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

enumerating globals
mariusco
#1 Posted : Thursday, October 18, 2018 4:49:14 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/11/2018(UTC)
Posts: 5
Location: toronto

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hi,

for a class

Code:
whatever <-
{
     o1=MyCppObject1(),
     o2=MyCppObject2(),
     o3=MyCppObject3(),
};


I can do:
Code:

  foreach(k, o in whatever){
      if("init" in o)
         o.init();
  }


How do I do this for globals:

Code:
     o1<-MyCppObject1(),
     o2<-MyCppObject2(),
     o3<-MyCppObject3(),


or

Code:
     o1=MyCppObject1(),
     o2=MyCppObject2(),
     o3=MyCppObject3(),


Code:
  foreach(k, o in /* what do I put here */){
      if("init" in o)
         o.init();
  }


Thank you

fagiano
#2 Posted : Friday, October 19, 2018 5:44:48 PM(UTC)
Rank: Advanced Member

Groups: Registered, Administrators
Joined: 6/11/2005(UTC)
Posts: 1,062

Thanks: 0 times
Was thanked: 80 time(s) in 62 post(s)
depends what is your "this" when you preform the <- operator

Code:

foreach(k, o in this){
   if("init" in o)
         o.init();
}


if this is the root table

Code:

foreach(k, o in getroottable()){
   if("init" in o)
         o.init();
}


Alberto
Follow me on Twitter @squirrellang
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.110 seconds.