PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, no array or string given in /am/paramount/vol/ecs/sites/whiley/wp-includes/class-wp-hook.php on line 298


  • No categories


Maps are similar to sets, but have additional constraints. The following example illustrates:

void ::main(System.Console console):
    amap = {"Hello"=>1,"World"=>2}
    amap["Hello"] = 2

Here, “amap” is a map from string keys to int values, where every key maps to exactly one value (but not necessarily vice-versa). Thus, the second println statement will print {"Hello"=>2,"World"=>2}.

There are some interesting operations supported for maps in Whiley:

void ::main(System.Console console):
    map = {"Hello"=>1,"World"=>2}
    map["Hello","World"] = 3
    rmap = ~map // take inverse of map

Here, we see a batch assignment of keys where both keys "Hello" and "World" are updated to hold value 3. Also, ~map computes the inverse of map which, in this case, gives: {3=>{"Hello","World"}}.