| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi All, Is there a limitation whereby a subclass cannot use attribute methods from the parent or is there a trick I can't find? My results return a non-initialised var, i.e., an uppercase method name. /* */ one = .one~new two = .two~new ::class one ::method one attribute ::method two return 'hello' ::method init self~one = 'hello' say self~one ::class two subclass one ::method init say self~one say self~two /* output */ hello ONE hello IBM Object Rexx 2.1.3 Phil ---- |
|
#2
| |||
| |||
| Phil wrote: > Hi All, > Is there a limitation whereby a subclass cannot use attribute methods from > the parent or is there a trick I can't find? My results return a > non-initialised var, i.e., an uppercase method name. > > /* */ > one = .one~new > two = .two~new > > ::class one > > ::method one attribute > > ::method two > return 'hello' > > ::method init > self~one = 'hello' > say self~one > > ::class two subclass one > > ::method init > say self~one > say self~two > > /* output */ > hello > ONE > hello > > IBM Object Rexx 2.1.3 Firstly, you should upgrade to ooRexx 3.2.0 ASAP, which is newer and stabler than IBM Object Rexx, from which sources ooRexx has evolved (http://www.ooRexx.org). Secondly, you need to make sure in your subclass, that the superclass is able to run its initialization method: /* */ one = .one~new two = .two~new ::class one ::method one attribute ::method two return 'hello' ::method init self~one = 'hello' say self~one ::class two subclass one ::method init self~init:super -- <-- let superclass' initialize say self~one say self~two The output then: hello hello hello hello HTH, ---rony |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.