Design Tips for Building Tag Clouds
Subject:   Correction
Date:   2006-06-15 04:39:25
From:   KristoferHoch
Response to: Correction

I believe the type of Associative array that Jim is speaking of, is a be more free than the Java generic.

Take the example you provided for instance. The phonebook is a
Map Object that can only accept two arguments. Both arguments MUST be of the
String type.

Map<String, String> phoneBook = new HashMap<String, String>();
phoneBook.put("Sally Smart", "555-9999");
phoneBook.put("John Doe", "555-1212");
phoneBook.put("J. Random Hacker", "555-1337");

In Perl, you can do all sorts of crazy things, for instance ...

use strict;
my %phonebook =
'Sally Smart' =>
name =>
'last' => 'Smart',
'first' => 'Sally',
'middle initial' => '',
'salutation' => [ qw(Ms. Lady) ],
'titles' => [ qw(PhD. Esquire M.D.) ],
'number' => '555-9999',

In this instance, I have associated Sally's full name to another associative array (really an anonymous associative array) which contains her full name and some more information.

If you wanted to do the same thing in Java you would, as Jim said, you will end up writing considerably more code.

1 to 2 of 2
  1. Correction
    2006-06-30 02:00:51 [View]

  2. Jim Bumgardner photo Hashes
    2006-06-15 08:15:43  Jim Bumgardner | O'Reilly AuthorO'Reilly Blogger [View]

1 to 2 of 2