in reply to Re: Array/List Strangeness
in thread Array/List Strangeness
my @var = (1,2,3);
@var = (); # @var is "empty", NO values
@var =undef; # @var has one value, undef
Yes, this is weird that an @var can have "nothing" in it, not even undef. This @var=() is often seen in code that "zero'es" out a @variable.
I have tried to avoid using the term "array" or "list" for these @vars. I remain curious as to when @var is an array and when @var is a list.
Update: I prefer the word "list" for Perl @vars because a list can be empty. I don't think of an array as "empty". In my thinking, an array has a null element, null pointer, etc. But the idea that it is "empty", in the same sense that a list can be "empty" (like a completely blank "to-do list) doesn't make sense to me.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Array/List Strangeness
by ikegami (Patriarch) on Aug 05, 2009 at 02:58 UTC | |
by Taulmarill (Deacon) on Aug 05, 2009 at 09:45 UTC | |
by jethro (Monsignor) on Aug 05, 2009 at 10:00 UTC | |
by LanX (Saint) on Aug 05, 2009 at 11:12 UTC | |
by jethro (Monsignor) on Aug 05, 2009 at 13:06 UTC | |
|