1 Reply Latest reply on Aug 17, 2007 9:04 AM by lichtjiang

    Use variables as index in Associative Array?

    lichtjiang
      It's known to use a string as index to call an array element as follows:

      City["Chicago"]={_county:Cook, _state:"IL", ...}

      But is it possible to use a variable to hold a state name and use that to reference an array element? It is helpful in cases when we iterate through a subset of all elements and which element to be selected is determined by some condition. For example, we can write codes like this (see below):

      It seems that "CityName" itself is literally treated as a "String" instead of a variable name in "City[CityName]". But is there another way around?

      Any thoughts? Thanks!