[Gambas-user] class within a class with a key

Bruce Steers bsteers4 at gmail.com
Fri Apr 14 15:56:09 CEST 2023


On Fri, 14 Apr 2023 at 13:55, Mayost Sharon <sharon at 455.co.il> wrote:

> Hello
> I need help on how to make a class within a class
> Attached is an example that gives me an error because I'm missing
> something that I can't figure out what to do
>
> I want to reach a state of:
> Print gb_Class1.students["key_01"].student_01
> Print gb_Class1.students["key_01"].student_02
>
>
> Thank you
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>


to use Keys like a collection you need to use Collection datatype.
Your Class2.class is not coded to work like a collection with Keys so it
does not work as you expect.

I got your code working by making the Class1.class  $students a collection
of Class2 objects.
Class2.class has no functions just the student_01 student_02 properties.

BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230414/04f60548/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: class_01-0.0.1.tar.gz
Type: application/gzip
Size: 12158 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230414/04f60548/attachment.gz>


More information about the User mailing list