Reputation: 376
If I define an array in the scope of a method, is it possible for another method to have access to it? I would make it global, but I only know the bounds of the array at the end of the first method.
Upvotes: 0
Views: 42
Reputation: 320
The only other option is you pass it as a parameter to your 'other method' if you dont want to make it global.
Otherwise I would suggest capturing both the array and its bounds in a class and save that as a global (instance variable) so you know both the array and its bounds when used in another method. You can check to make sure the bounds and the array are valid before attempting to use it to avoid run time errors.
Upvotes: 1