Map data type usage

Hi,

I would like to know how to use map, specifically initializing it. For example I do not know why I get “Unexpected null value” error:

map[string, string] values;
function void myFunc(string key, string value)
{
if(values==null)
values[key] = “”;

values[key] = value;
}

Thanks.

Hi U00171,

can you be more specific? For me Reformat with code:


//#CTL2

map[string, string] values;

function void myFunc(string key, string value)
{
if(values==null)
values[key] = "";

values[key] = value;
}

function integer transform() {
	myFunc(lowerCase($in.0.field1), upperCase($in.0.field1));
	return OK;
}

Works as expected. What version of Clover you use?

Cannot it be that your “key” parameter is null? So error is not indicating null map, but null value used as key?