From: Mat Brown Date: 2010-02-28T06:32:47+09:00 Subject: Re: scope question --000e0cd359b6a50be804809bc1e8 Content-Type: text/plain; charset=UTF-8 Method definitions are not closures, so they don't have access to external local scope. Use $vara to declare a global, if you really think that's a good idea. On Feb 27, 2010 4:27 PM, "Nick Brown" wrote: Consider the following Sinatra app: require 'sinatra' vara = "foo" VARB = "bar" helpers do def geta vara end def getb VARB end end get '/a' do geta end get '/b' do getb end When I run that and browse to /b, it displays "bar". When I browse to /a, however, it produces the error: "undefined local variable or method `vara'". Why do these two variables differ in scope? How can I declare a variable that has global scope but is not a constant? Thanks in advance... -- Posted via http://www.ruby-forum.com/. --000e0cd359b6a50be804809bc1e8--