At 18:34 07.03.01 +0900, Dave Thomas wrote:
>Tammo Freese <tammo.freese / offis.de> writes:
>
>> Is there any case where inverting a hash that is not one-to-one
>> makes sense? (You cannot know the result!)
>
>    # Here's a hash mapping image files to the names
>    # of people they portray
>
>    photoSubjects = {
>      "a.gif" => "Dave",
>      "b.gif" => "Fred",
>      "c.gif" => "Dave",
>      "d.gif" => "Tammo",
>        ..
>      "zzz.gif" => "Fred"
>    }
>
>    .....
>
>    # I need to display a picture of Dave
>
>    display(photoSubjects.invert['Dave'])

OK, exception throwing would be a bad thing here.

Thank you for your help!


-
Tammo Freese
freese / acm.org