RE: $self def

2001-06-20 Thread John Edwards
Are you trying to use a hash?? --- @myArray = qw(one two three four); &new; sub new { $self{'Next'} = \@myArray; } print "Element 0 is $self{'Next'}->[0]\n"; --- You can't specifiy the size of the array, it's dynamic. Just enter your data into the array and it will change size accordi

Re: $self def

2001-06-20 Thread Randal L. Schwartz
> "Brett" == Brett W McCoy <[EMAIL PROTECTED]> writes: Brett> On Wed, 20 Jun 2001, Nick Transier wrote: >> You are saying I cannot set the size of an array? I understand that you do >> not have to, but I need to in this case so that my iteration loops work >> correctly. Brett> No you don't:

Re: $self def

2001-06-20 Thread Brett W. McCoy
On 20 Jun 2001, Randal L. Schwartz wrote: > The problem with references is that they have a very hard to explain > but completely intuitive interface. :) Gee, just like pointers in C! :-) -- Brett http://www.chapelperilous.net/btfwk/ --

RE: $self def

2001-06-20 Thread Brett W. McCoy
On Wed, 20 Jun 2001, Nick Transier wrote: > You are saying I cannot set the size of an array? I understand that you do > not have to, but I need to in this case so that my iteration loops work > correctly. No you don't: foreach $i (0..@array) { print "$array[$i]\n"; } @array used in a

Re: $self def

2001-06-20 Thread Randal L. Schwartz
> "Nick" == Nick Transier <[EMAIL PROTECTED]> writes: Nick> So then would I access the nth element by Nick> @{$self->{Next}}[n] ?? Uh, no. That looks like @foo[3], which works for some broken values of "works". You want $foo[3], so to backtrace that, use ${$self->{Next}}[$n], also written

RE: $self def

2001-06-20 Thread Nick Transier
You are saying I cannot set the size of an array? I understand that you do not have to, but I need to in this case so that my iteration loops work correctly. >From: John Edwards <[EMAIL PROTECTED]> >To: 'Nick Transier' <[EMAIL PROTECTED]>, [EMAIL PROTECTED] >Su

Re: $self def

2001-06-20 Thread Nick Transier
So then would I access the nth element by @{$self->{Next}}[n] ?? >From: [EMAIL PROTECTED] (Randal L. Schwartz) >To: "Nick Transier" <[EMAIL PROTECTED]> >CC: [EMAIL PROTECTED] >Subject: Re: $self def >Date: 20 Jun 2001 09:29:41 -0700 > > >>>>

Re: $self def

2001-06-20 Thread Randal L. Schwartz
> "Nick" == Nick Transier <[EMAIL PROTECTED]> writes: Nick> Given this is my definition for self in some new constructor: Nick> sub new { Nick>$self { Nick> Next => @[Max_Level], Nick>} Nick> } Nick> First, is this the proper way to have Next be a reference to a

Re: Self Def

2001-06-19 Thread Chas Owens
Well, in this case it was a cargo cultism. I understand why one may want to do this, but that was not my intent when I was writing this; I just grabbed an example constructor. I should have thought about the choice to make "new" a function that could be called by both the class and the object, b

Re: Self Def

2001-06-19 Thread Randal L. Schwartz
> "Chas" == Chas Owens <[EMAIL PROTECTED]> writes: Chas> sub new { Chas> my $class = shift; Chas> $class= ref($class) || $class; PLEASE stop doing this. I know there's a Very Popular Tutorial included with your documentation that says that's a Right Way of doing it, but

Re: Self Def

2001-06-19 Thread Chas Owens
On 19 Jun 2001 16:02:43 -0500, Nick Transier wrote: > Given that I am trying to define an object attribute which is an array of > references to other object of the same type, how do I define this in the > $self portion of my sub new constructor? This is what I have, will this > work? Next is me

Re: Self Def

2001-06-19 Thread Nick Transier
The thing is, I want to set the array reference later and not when the object is being created. >From: [EMAIL PROTECTED] (Randal L. Schwartz) >To: "Nick Transier" <[EMAIL PROTECTED]> >CC: [EMAIL PROTECTED] >Subject: Re: Self Def >Date: 19 Jun 2001 14:12:13

Re: Self Def

2001-06-19 Thread Randal L. Schwartz
> "Nick" == Nick Transier <[EMAIL PROTECTED]> writes: Nick> Given that I am trying to define an object attribute which is an array Nick> of references to other object of the same type, how do I define this Nick> in the $self portion of my sub new constructor? This is what I have, Nick> will t