in reply to Multidimesional hashs in Perl, C++, C# and Perl6
I'll add some java to the mix:
package Foo; import java.util.HashMap; public class Bar { public static void main(String... args) { HashMap<String, HashMap<String, Integer>> map = new HashMap<Stri +ng, HashMap<String, Integer>>(); map.put("A", new HashMap<String, Integer>()); map.get("A").put("A", 1); map.get("A").put("B", 2); map.put("B", new HashMap<String, Integer>()); map.get("B").put("A", 4); map.get("B").put("B", 8); for(String k: map.get("B").keySet()) { System.out.println(k + " - " + map.get("B").get(k)); } } }
Java would be the language I use most after Perl. When using Java, I often think about how much I miss the first class support for lists and hashes that we have in Perl. But, I find that when I don't have that first class support, I write things differently anyhow. If it is harder to make and use a hash, I won't use a hash as often.
That being said, I really love Java's hierarchy of collections. There are many powerful types of lists and hashes, and Generics really simplify things.
Ted Young
($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)
|
|---|