From: gabriele renzi Date: 2004-09-14T20:14:57+09:00 Subject: Re: Catching undefined global variable errors George Moschovitis ha scritto: > Sorry everyone, > > my example was wrong, THIS is the surprising code: > > $the_key = "key1" > > a = { "key1" => 1, "key2" => 2} > > unless a[$the_ley] # orthographic error !!! > # ruby doesnt catch this error > puts "SURPRISE!!" > end > > the orthographic error is in the variable. Shouldnt this be catched by > the interpreter ? Any ideas ? > I see what you're saying. I think when globals or instance variables are acessed but not yet initialized they should raise and exception, instead of assuming a nil value. At least there should be some kind of global switch to allow this, something like $EXPLICIT_VARIABLES.