Hi, 

Here's something that bit me:

[0,1].each {|n|
	print "n: #{n}\n"
	case n
		when 0
			a = 0
			print "a: #{a}\n"	# -> 0
			# never heard of b
		when 1
			b = 1
			print "a: #{a}\n"	# Name Error
			print "b: #{b}\n"
	end
}

I would have expected the local variable 'a' to be defined the first
time the case statement is executed (i.e., when n == 0), and to remain
in scope from then on. But this appears not to be the case, as I get
a NameError when n == 1.

I gather that variables defined in a 'when' clause are local to the
clause? Or did I miss any obvious thing? 

My apologies if this question was already asked. I did a quick search
on the archive and in th FAQ, but maybe it wasn't enough.

Thanks


Thomas

-- 
Thomas Junier	
Swiss Institute of Bioinformatics
http://pcisrec-d402b.unil.ch/~tjunier