What .Net object corresponds to an IronRuby hash -
i want call c# method ironruby script results in ruby hash. tried dictionary stays is.
public dictionary<string, string> gethash() { dictionary<string, string> hash = new dictionary<string, string>(); hash.add("a", "1"); hash.add("b", "2"); return hash; }
i'd able use in ironruby script hash
myhash = scopeobj.gethash() myhash.each{ |k,v| print("#{k}=#{v}") }
the results of are:
[a, 1]= [b, 2]=
it doesn't work since items in .net dictionary keyvaluepair instances.
you can workaround pretty easily, single line of conversion code:
d = scopeobj.get_hash h = hash[*d.collect { |x| [x.key,x.value] }.flatten] h.each { |k,v| puts k,v }
Comments
Post a Comment