Front page | perl.perl6.language |
Postings from February 2005
Re: Valid hash keys?
Thread Previous
|
Thread Next
From:
Luke Palmer
Date:
February 27, 2005 01:20
Subject:
Re: Valid hash keys?
Message ID:
20050227092059.GA19018@navi.cx
Luke Palmer writes:
> Autrijus Tang writes:
> > Just a quick question: Is Hash keys still Strings, or can they be
> > arbitary values?
>
> They can be declared to be arbitrary:
>
> my %hash is shape(Any);
>
>
> > If the latter, can Int 2, Num 2.0 and Str "2" point to different
> > values?
>
> That's an interesting question. Some people would want them to, and
> some people would definitely not want them to. I think the general
> consensus is that people would not want them to be different, since in
> the rest of perl, 2 and "2" are the same.
I forgot an important concretity. Hashes should compare based on the
generic "equal" operator, which knows how to compare apples and apples,
and oranges and oranges, and occasionally a red orange to an apple.
That is:
3 equal 3 ==> true
3 equal { codeblock } ==> false
3 equal "3" ==> true
Luke
Thread Previous
|
Thread Next