How would one reference a var defined in the workspace within a class? For example, suppose I have a list of items, as enclosed character arrays, which I want to reference within a class:
myList←('apple' 'banana' 'cherry' 'date') ⍝ myList shows up in )vars
then in my class (e.g. ○FruitCake ) ...
∇z←indexOf fruit
z←myList ⍳ ⊂fruit
do I need to do something special so that myList is "visible" within the class? When I try something like the above, I get a Value Error for myList
Thanks for your help!
Access to workspace )vars within a class?
-
- Posts: 431
- Joined: Fri Oct 03, 2008 4:14 pm
Re: Access to workspace )vars within a class?
First, you probably don't want to really do that if you can avoid it.
But if you insist, then use an absolute path to the variable like:
If the variable is in fact a constant, then just define it as a read-only public field on the class. If it needs to be used by many classes, then you might consider creating a base class that all classes inherit from.
But if you insist, then use an absolute path to the variable like:
#.myList
If the variable is in fact a constant, then just define it as a read-only public field on the class. If it needs to be used by many classes, then you might consider creating a base class that all classes inherit from.