Hey there everyone, I'm trying to check the local_variables from Bitmap Class, but it's 'private'.
I printed Bitmap.local_variables
Here is what was raised lol:
Quote---------------------------
Project1
--------------------------
private method `local_variables' called for Bitmap:Class
---------------------------
OK
---------------------------
Im trying to figure out the variable which initializes SDL.
I was almost sure it was an instance variable, but when I reversed the dll, it showed up a blank window only.
The local_variables one is the only that raises that private error.
As far as I know, the only way to access that kind of methods is inside of a method of the same class, although we can't use 'self.local_variables' to figure it out since it is a private method, not a protected one.
Any ideas?
Thanks
class Bitmap
def get_local_variables
return self.local_variables
end
end
Same thing shows up.
This is so strange lol
Local_variables shouldn't be inaccessible, instance_variables do -.-
That's because instance_variables isn't private. That's just the way it is.
lol, but it doesn't return anything either -.- Besides, all the remake bitmap classes i've seen till now, uses an instance variable, so it can be used in all methods.
If only local_variables seems to be private...how can I get their names? :P
@Edit:
:facepalm:
F0 said Bitmap class is made in C, no damn way we'll be able to get the instance variable :P
Shall we forget about this? :P
You don't have to. Local variables are all local within the scope of a method. It doesn't even make sense to use it outside of the class so just leave it.
First of all, I wanted them to be used inside the same class :P
last post edit:
:facepalm:
F0 said Bitmap class is made in C, no damn way we'll be able to get the instance variable :roll:
Shall we forget about this? :^_^':
Yeah, you should. xD
I didn't say you
couldn't get the instance variables, I said it is a bad and inefficient idea.
You can access private methods with Ruby's "send" method. The thing is, there is absolutely nothing you can do wth them. If you want to have a variable accessible, make an instance variable.
b = Bitmap.new(32, 32)
p b.send(:local_variables)
No, with the internal classes you actually can't get the instance_variables, because they haven't been exposed to Ruby.
Well I was reading stuff about private and protected methods and variables, and it seems that blizz is right about what he said just now:
Quote from: Blizzard on August 21, 2011, 04:20:32 pm
No, with the internal classes you actually can't get the instance_variables, because they haven't been exposed to Ruby.
About local ones, F0 is absolutely right, and, as he said, I can't do anything with them, since they're local.
The instance_variables, are the ones that could be used, and my interest was in the one that initializes SDL...
Shall I had [Resolved] to the topic name? or any other thing? lol
Yeah, [Resolved] is fine.