4

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!

alexlz
  • 618
  • 1
  • 10
  • 24

2 Answers2

5

Please try the following

...
if (typeof(conPeek(a, i)) == Types::Container)
{
    info("It's a container");
}
...
DAXaholic
  • 33,312
  • 6
  • 76
  • 74
1

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)));
  }
alexlz
  • 618
  • 1
  • 10
  • 24