alexlz
alexlz

Reputation: 666

How to get one container from another container?

I have a container that includes many items and some of those items are containers. And I need to get those internal containers. What is the best practice fot that?

My solution is kinda ugly for me :(

container a = [1, 2, ["one","two","three"]];
container b;
int i;
;

for (i = 1; i <= conLen(a); i++)
{
    try
    {
        b = conPeek(a, i);
        info(strFmt("%1", conPeek(b,1)));//here should be some logic with b items
    }
    catch
    {
         info(strFmt("NOT A CONTAINER %1",  conPeek(a, i)));
    }
}

Thanks in advance!

Upvotes: 4

Views: 2640

Answers (2)

alexlz
alexlz

Reputation: 666

Ok, it was really easy. But maybe it will be helpfull for someone in the future.

  if(typeOf(conPeek(a, i)) == Types::Container)
  {
        b = conPeek(a, i);
        info(strFmt("%1", conPeek(b,1)));
  }

Upvotes: 1

DAXaholic
DAXaholic

Reputation: 35358

Please try the following

...
if (typeof(conPeek(a, i)) == Types::Container)
{
    info("It's a container");
}
...

Upvotes: 5

Related Questions