Re: RE: [Flashcoders] Casting to Array

2007-07-20 Thread John Mark Hawley
David's suggestion doesn't actually cast to array, though -- it makes a shallow 
copy of the array and returns it. This will lead you to many tricky bugs.

If you really *really* need type checking on arrays, make a List class to wrap 
arrays and only use that.


 
 From: Danny Kodicek [EMAIL PROTECTED]
 Date: 2007/07/20 Fri AM 10:07:47 CDT
 To: flashcoders@chattyfig.figleaf.com
 Subject: RE: [Flashcoders] Casting to Array
 
   As it's AS2, you might think about making it so 
  doMyArrayFunction will not expect an array, but will take anything:
  
  class ArrayTest {
  
  public function ArrayTest(a) {
  trace(a[0]);
  }
  
  }
  
  
  
  new ArrayTest([1,2,3,4]);
  
  works fine.
 
 Yes, but I'm trying to do things 'properly' :)
 
 I've been quite enjoying the discipline of strong typing and it seems a
 shame to lose it for a little technicality. I like David's suggestion, which
 I'd imagine works pretty fast.
 
 Thanks
 Danny
 
 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com
 

--
John Mark Hawley
The Nilbog Group
773.968.4980 (cell)

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: RE: [Flashcoders] Casting to Array

2007-07-20 Thread David Ngo
That is correct. If you need the reference to the actual array, then I would
consider using a class to help cast your data as suggested by others. But if
you just need the data and not the actual reference (meaning you don't need
to persist that data anywhere else), then my solution should be fine.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of John Mark
Hawley
Sent: Friday, July 20, 2007 1:44 PM
To: flashcoders@chattyfig.figleaf.com
Subject: Re: RE: [Flashcoders] Casting to Array

David's suggestion doesn't actually cast to array, though -- it makes a
shallow copy of the array and returns it. This will lead you to many tricky
bugs.

If you really *really* need type checking on arrays, make a List class to
wrap arrays and only use that.


 
 From: Danny Kodicek [EMAIL PROTECTED]
 Date: 2007/07/20 Fri AM 10:07:47 CDT
 To: flashcoders@chattyfig.figleaf.com
 Subject: RE: [Flashcoders] Casting to Array
 
   As it's AS2, you might think about making it so 
  doMyArrayFunction will not expect an array, but will take anything:
  
  class ArrayTest {
  
  public function ArrayTest(a) {
  trace(a[0]);
  }
  
  }
  
  
  
  new ArrayTest([1,2,3,4]);
  
  works fine.
 
 Yes, but I'm trying to do things 'properly' :)
 
 I've been quite enjoying the discipline of strong typing and it seems a
 shame to lose it for a little technicality. I like David's suggestion,
which
 I'd imagine works pretty fast.
 
 Thanks
 Danny
 
 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com
 

--
John Mark Hawley
The Nilbog Group
773.968.4980 (cell)

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com