title: Declaring an instance variable outside of `initialize` method
body: <p>I have been taught to declare my instance variables with <code>def initialize</code>. I have been under the impression that I could declare instance variables only within my <code>initialize</code> methods.</p>
  
  <p>Nevertheless, I declared an instance variable <code>@foo</code> outside my <code>initialize</code> method, and made it work as I intended:</p>
  
  <pre><code>class FooBar
      def initialize(bar)
          @bar = bar
      end
  
      def foo_as_instance_var
          @foo = @bar.split(' ')
          @foo
      end
  end
  
  x = "something wicked this way comes"
  y = FooBar.new(x)
  puts y.foo_as_instance_var
  </code></pre>
  
  <p>Why am I able to declare an instance variable outside of <code>initialize</code> method?  Since I can declare instance variables in any method, is there a best practices rule I should follow, regarding where to declare instance variables (i.e., declare them within <code>initialize</code>) or does it not matter?</p>