Return value type from a map

Return value type from a map

Hi

  i'm confused about the map's 'GET' function return value type
  form the tutorial, it seems not have to do explicit casting
  https://help.zoho.com/portal/en/community/topic/map%28%29-tutorial-%28intermediate%29

  but when i try the following codes (firstly, create a "num_val" number field)

  vars = map();
  vars.put("Num", 123);
  num_val = vars.get("Num");

  i got error message like this
  Variable 'num_val' is already defined of datatype 'BIGINT' but trying to update 'STRING' datatype

  so i have to do a type casting explicitly like this

  vars = map();
  vars.put("Num", 123);
  num_val = vars.get("Num").toLong();

  same for other variable types (date, time)
  the most confusing part is about "BOOLEAN" type

  vars.put("Bool", true);
  bool_val = vars.get("Bool");

  i can only retrieve a 'null' value, and can not find a way to cast back to boolean
  to compromise, i revise the codes like below

  vars.put("Bool", "true"); // store a string value
  bool_val = (vars.get("Bool") == "true");

  this lowers down the readability
  is there any better way to pass boolean in map
  please advise
  thanks

Regards, Matthew