J
Joachim Wuttke
Dear experts:
I am not happy with the following code fragment.
It works, but the introduction of the auxiliary
variable «this» is not very elegant. Is there another
way to tell the TkButton constructor that «buttonPressed»
is a member of the class it was called from ?
Regards, Joachim
class MyClass
def initialize( frame )
...
this = self # <- this is ugly, though it solves the problem
TkButton.new( frame ) {
text 'press here'
command proc { this.buttonPressed } # <- here is the problem
}
...
end
def buttonPressed
puts "here we are"
end
end
__________________________________________________________
Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min.
weltweit telefonieren! http://freephone.web.de/?mc=021201
I am not happy with the following code fragment.
It works, but the introduction of the auxiliary
variable «this» is not very elegant. Is there another
way to tell the TkButton constructor that «buttonPressed»
is a member of the class it was called from ?
Regards, Joachim
class MyClass
def initialize( frame )
...
this = self # <- this is ugly, though it solves the problem
TkButton.new( frame ) {
text 'press here'
command proc { this.buttonPressed } # <- here is the problem
}
...
end
def buttonPressed
puts "here we are"
end
end
__________________________________________________________
Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min.
weltweit telefonieren! http://freephone.web.de/?mc=021201