Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Open
vito opened this Issue · 0 comments

1 participant

@vito

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
Something went wrong with that request. Please try again.