Access to workspace )vars within a class?
2 posts
• Page 1 of 1
Access to workspace )vars within a class?
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!
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!
- sloughin
- Posts: 2
- Joined: Mon Sep 12, 2011 8:38 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.
- paulmansour
- Posts: 429
- Joined: Fri Oct 03, 2008 4:14 pm
2 posts
• Page 1 of 1
Return to Object Oriented Programming
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group