From: "David A. Black" Date: 2008-10-28T01:35:40+09:00 Subject: Re: Quick Scope Question Hi -- On Tue, 28 Oct 2008, Daniel Malcolm Webb [dbw] wrote: > Q_txt = res_q[0][1] > (0..10).each do |qt| > question_text = q_txt.scan(/\w+/)[qt] > end > > when I access question_text after, obviously it's out of scope what am I > missing here? Blocks have a kind of one-way valve local scope. Variables that already exist before the block will exist in the block. Variables that are created in the block do not survive past the block. David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL Advancing with Rails January 19-22 Fort Lauderdale, FL * * Co-taught with Patrick Ewing! See http://www.rubypal.com for details and updates!