Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Closures blocking out the surrounding scope for classes/instances #2

Open
vito opened this Issue Apr 14, 2010 · 0 comments

Comments

Projects
None yet
1 participant

vito commented Apr 14, 2010

An example, with the Android API:

hello = self
btn.setOnClickListener do
  def onClick(v)
    return if hello.txt.getText.toString.length == 0
    hello.addMessage("hellotester", Hello(v.getContext).txt.getText.toString)
    message = Bundle.new
    message.putString("say", Hello(v.getContext).txt.getText.toString)
    Message m = Message.obtain
    m.setData(message)
    hello.client.handler.sendMessage(m)
    hello.txt.setText("")
  end
end

hello is not accessible. Workaround here is to use Hello(v.getContext) (where Hello is the name of the class).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment