There doesn't seem to be a way to get the parametrized types of a Map.
Map
With a List, there is List.of that will tell you, "oh, this is a list of Ints".
List
List.of
With a Func, there is returns to tell you the return type and params to extract the parameter types.
Func
returns
params
But there is no method in Map that would say "The keys of this map are Strs" or "The values of this map are Uris". It might be nice to have.
I don't have a method directly on Map, but you can get it pretty easily using Type.params:
Type.params
fansh> m := ["quick":10sec, "long":10min] [quick:10sec, long:10min] fansh> m.type.params["K"] sys::Str fansh> m.type.params["V"] sys::Duration fansh> m.type.params [V:sys::Duration, M:[sys::Str:sys::Duration], K:sys::Str]
Likewise for functions:
fansh> f := |Int x->Str| { x.toHex } |sys::Int->sys::Str| fansh> f.type.params["A"] sys::Int fansh> f.type.params["R"] sys::Str fansh> f.type.params [A:sys::Int, R:sys::Str]
Login or Signup to reply.
tactics Mon 27 Apr 2009
There doesn't seem to be a way to get the parametrized types of a
Map
.With a
List
, there isList.of
that will tell you, "oh, this is a list of Ints".With a
Func
, there isreturns
to tell you the return type andparams
to extract the parameter types.But there is no method in
Map
that would say "The keys of this map are Strs" or "The values of this map are Uris". It might be nice to have.brian Mon 27 Apr 2009
I don't have a method directly on Map, but you can get it pretty easily using
Type.params
:Likewise for functions: