ModScript question - Map object '.insert" method doesn't seem to work as documented

I attempted to solve this through tech support but failed.

Lines 4 and 5 reassign the variable "mymap_pair2". Why does this fail?
Lines 11 and 12 attempt to add a Map_Pair object to a Map. According to the documentation this should be a valid operation. Lines 8 and 9 do this and don't fail. Why do lines 11 and 12 fail?

// this is line 0
var my_map = Map();                                         // works. -- my_map is a : chai:Map :: .size = '0' :: to_json = '{}'

var mymap_pair2 = Map_Pair();                               // works. -- mymap_pair2 is a : chai:Map_Pair :: .first() is a chai:string ; .second() is a chai:UNDEFINED
mymap_pair2 = Map_Pair();                                   // DOES NOT WORK --- WHY???
mymap_pair2 = Map_Pair("key string 3","value string 3");    // DOES NOT WORK --- WHY???

my_map["key string 1"] = "value string 1" ;                 // works. -- my_map is a : chai:Map :: .size = '1' :: to_json = '{"key string 1" : "value string 1"}'
my_map.insert(["key string 2":"value string 2"]);           // works. -- my_map is a : chai:Map :: .size = '2' :: to_json = '{"key string 1" : "value string 1","key string 2" : "value string 2"}'
var mymap_pair = Map_Pair("key string 3","value string 3"); // works. --mymap_pair is a : chai:Map_Pair :: .first() is a : chai:string ='key string 3' ; .second() is a : chai:string ='value string 3'

my_map.insert(mymap_pair);                                  // DOES NOT WORK --- I THINK THIS SHOULD WORK ACCORDING TO DOCUMENTATION
my_map.insert(Map_Pair("key string 4","value string 4"));   // DOES NOT WORK --- I THINK THIS SHOULD WORK ACCORDING TO DOCUMENTATION
// this is line 13

Tags:

Parents
  • Suggested Answer

    0  

    I ran into a similar problem today and at least for my SBM 12.2 system, the reason for Map::insert(Map_Pair) not working is simple:
    There is no such method defined.

    The following code 

    generates the error message

    which tells that there actually is just one insert method defined for the Map class, and that method takes another Map instance as a parameter.
    No method that takes a Map_Pair instance is present.

    So, either the SBM documentation is wrong, the method implementation is missing, or both :)

    Note, however, that adding the missing method is really simple:

Reply
  • Suggested Answer

    0  

    I ran into a similar problem today and at least for my SBM 12.2 system, the reason for Map::insert(Map_Pair) not working is simple:
    There is no such method defined.

    The following code 

    generates the error message

    which tells that there actually is just one insert method defined for the Map class, and that method takes another Map instance as a parameter.
    No method that takes a Map_Pair instance is present.

    So, either the SBM documentation is wrong, the method implementation is missing, or both :)

    Note, however, that adding the missing method is really simple:

Children
No Data