[Gambas-user] Object array code gives weird results

Jose J. Rodriguez joe1962 at ...626...
Fri May 19 17:38:32 CEST 2006


On 5/19/06, Timothy Marshal-Nichols
<timothy.marshal-nichols at ...247...> wrote:
>
> > -----Original Message-----
> > From: gambas-user-admin at lists.sourceforge.net
> > [mailto:gambas-user-admin at lists.sourceforge.net]On Behalf Of Jose J.
> > Rodriguez
> > Sent: Friday, 19 May 2006 00:12
> > To: gambas-user at lists.sourceforge.net
> > Subject: [Gambas-user] Object array code gives weird results
> >
> >          PartInfo.Push(vPI)
>
> On the above line you a pushing an object. So at the end of the loop
> all items in the array are set to the same object.

Well, it's the only way I've found so far in the docs, forums or
examples that is similar to the user defined type arrays from VB.

> To overcome the problem push the value of the object or create a new object
> with the value you want.

Sorry but, could you give an example? Not really sure how to do this.
>
> So on the line below you are always looking the same object. You
> always get the value you last set this object to.

I sort of figured it was something like that.

> You might not like this behaviour. But it is the same as in most
> programming languages with objects.

I don't have any problem with it, its just not clear to me from the
docs. As to being the same in most, I can't really tell. OOP is still
somewhat a grey area for me. I use objects and classes here and there,
but mostly can't quite tell why or when to use the approach. Also, a
concept like the UDTs seems more logical to me in this instance.
Gambas sort of "forces" me to program in a more OOP way, which I see
as a good thing mostly.

Thanks,
Joe1962




More information about the User mailing list