From: Yohanes Santoso Date: 2002-04-01T00:28:30+09:00 Subject: scoping question I was working on this code: anArray = ["apple", "orange", "papaya"] anArray.each do |x| anArray[0].diff(x).each do |x| if x[0] > maxDiffPos then maxDiffPos = x[0] end if x[0] < minDiffPos then minDiffPos = x[0] end end puts "current_item => #{x}" end What surprises me is that instead of getting: current_item => apple current_item => orange current_item => papaya What I got was: current_item => 250 current_item => 251 current_item => 252 What's going on? Shouldn't variables declared within the do..end and/or {..} block, are visible only from within the block? How could it messes up the outer x? YS.