Re: question about data structures - what does $# mean?
Ed <edwardjameshartnett@xxxxxxxxx> wrote:
So to get the number of elements in the array I try:
$#{$d->{sid}}
Wrong operator. If you want the number of elements in an array then just
use the array in scalar context, if nothing else then by using scalar().
$# OTOH will return the last index in that array, which is one less than
the number of elements unless someone messed around with $[.
But that does not work. It gives me 0.
Just as it should.
Meanwhile, this does work:
scalar(@{$d->{sid}})
Surprise, surprise.
jue
.
Relevant Pages
- Re: Unexpected behavior with multidimensional arrays
... this not being a violation of the principle of least surprise (and yes, ... constructing an array and adding the same object multiple ... hidden behavior is usually a bad thing. ... (comp.lang.ruby) - Re: Unexpected behavior with multidimensional arrays
... this not being a violation of the principle of least surprise (and yes, ... still have not glue why one would want an array whose elements are ... hidden behavior is usually a bad thing. ... In fact, anything that in done with Array.new(n, obj) can be done with Array.new. ... (comp.lang.ruby) - Re: PAS loop faster than BASM
... > I created a BASM function that searches through an array of integers ... To my surprise, it benchmarks at about 10 times slower ... (borland.public.delphi.language.basm) - Re: Framework 2.0 array redim unsatisfactory performance
... Not a surprise, most likely it is implemented as single-linked ... Implements the System.Collections.Generic.IListinterface using an array ... How are you determining "at least 5 additional bytes for each entry"? ... | The reason why I test Array is because I need a dynamic data structure ... (microsoft.public.dotnet.languages.vb) - Case: For-loop faster than built-in functions.
... the 3rd dimention. ... The test-case involved a 100x100x300 array of double data. ... built-in method would be slower is a great surprise to me. ... (comp.soft-sys.matlab) |
|