1
votes

hello want to know how are associative arrays passed as return values

code:

function abc()
begin
int value[string][string];
value = def();
end

function int def()
begin
int new_value[string][string];
//logic to populate the array
return new_value;
end

I am seeing the following error: The type of target is int. While, the type of source is int$[string][string].

How to handle this and pass the assosciative array seamlessly?

1

1 Answers

4
votes

For a function to return an aggregate type, you need to declare a typedef first, then use that as the return value.

typedef int AA_t[string][string];
function AA_t def();
  AA_t new_value; 
  //logic to populate the array
  return new_value;
endfunction

Once you have the typedef you might as well use it everywhere.