hashCode() is a method that every Java object has, and since CF is Java,
every CF object has it as well, including strings, numbers, everything. You
use it like any other method, except that you needn't have an CF object
(created with createObject() or CFOBJECT) to call it on.
s = "my String";
writeoutput(s.hashCode() & "<br />");
d = 0.454;
writeoutput(d.hashCode() & "<br />");
st = structNew();
st['s'] = s;
writeoutput(st.hashCode() & "<br />");
st['d'] = d;
writeoutput(st.hashCode() & "<br />");
the method will return a string that is as unique to the object as possible,
but the same as every other object that is considered 'equal' to the object.
'equal' is determined by the Java equals() method, which defaults to the
memory location of the class, but is overridden by many classes, most
notably the String class. This will output true three times, even though
the objects are different. (That's actually a lie, but it still illustrates
the point).
s = "my String";
s2 = "my String";
if (s EQ s2)
writeoutput("true<br />");
if (s.equals(s2))
writeoutput("true<br />");
if (s.hashCode() EQ s2.hashCode())
writeoutput("true<br />");
Here's the output I got on my system (for both snippets):
1804807461
45751061
6774247
7476378
true
true
true
---
Barney Boisvert, Senior Development Engineer
AudienceCentral
[EMAIL PROTECTED]
voice : 360.756.8080 x12
fax : 360.647.5351
www.audiencecentral.com
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Brad Howerter
> Sent: Thursday, August 21, 2003 3:28 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: [CFCDev] cfdump problem
>
>
> How do you use hashcode()? I can't find any documentation for it. Please
> provide an example.
>
> -----Original Message-----
> From: Chafic Kazoun [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 21, 2003 4:13 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] cfdump problem
>
>
> The main reason for this is that Flash's debugging tools don't always meet
> your needs and you resort to dumping an object to make
> sure your code is doing what it needs to do. The debugger in
> Flash is also
> really really slow and dumping out the object rather
> than dealing with the slow-downs is much easier...
>
> Thanks
>
> Chafic
> _____________________________
> Work: http://www.blinex.com
> Blog : http://www.rewindlife.com
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Barney Boisvert
> Sent: Thursday, August 21, 2003 5:58 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] cfdump problem
>
> What do you use recursive structures in Flash for? especially with such
> frequency.
>
> ---
> Barney Boisvert, Senior Development Engineer
> AudienceCentral
> [EMAIL PROTECTED]
> voice : 360.756.8080 x12
> fax : 360.647.5351
>
> www.audiencecentral.com
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Behalf Of Samuel Neff
> > Sent: Thursday, August 21, 2003 2:09 PM
> > To: [EMAIL PROTECTED]
> > Subject: RE: [CFCDev] cfdump problem
> >
> >
> >
> > There are lots of situations where this recursive structures are
> > useful. I
> > haven't used them in CF, but in Flash we do it all the time.
> >
> > Here's a mini cfdump that just does structures and handles the recursive
> > issue. It uses the hashCode() Barney mentioned. hashCode() is a Java
> > function available on any object that creates an (almost) unique
> > key for the
> > object. I say almost 'cause it is theoretically possible to create a
> > duplicate, but it's really rare.
> >
> > You'd have to expand it to work with arrays and (if you care)
> > xml, java and
> > com objects.
> >
> > HTH,
> >
> > Sam
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/2003
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/2003
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).