in reply to Re: A Perl vs. Java fight brews
in thread A Perl vs. Java fight brews
Java will require something like value = hash_name.get( key_name ); instead of the more compact value = hash_name{key_name}. This is magnified for, two or three dimensional hashes, for example compare $myhash{$key}{$key2} to myhash.get(key).get(key2).Don't forget about the need for casting, which makes matters worse. Java "hashes" (Java has many basic hash types, so you have to choose an implementation first) can contain any kind of object, so when you retrieve a value, you have to tell it what kind of object it is, before you can do anything with it. So your nested hash example really has to become more like
where datatype and hashtype need to be replaced with the real class names for the kind of objects you're using. Are you appalled enough, yet?value = (datatype)((hashtype)myhash.get(key)).get(key);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: A Perl vs. Java fight brews
by philcrow (Priest) on Jul 25, 2006 at 13:23 UTC |