Nicholas Van Weerdenburg wrote:
>  @myvar ||= 1 # initialize @myvar, but only if it's nil
>  @myvar = 1 unless defined?(@myvar)
> 
> Ah, the first idiom is neat. I hadn't seen that one. Unfortunately, the 
> issue I still have is that I don't have a single place where I want to 
> set these- the variable is in many methods.

Good point. In that case, define a method:

def myvar
   @myvar ||= 1
end

It works more or less as if you defined it with attr_reader.

Then make sure you always call the method rather than referencing the 
instance var directly.