<!DOCTYPE html>
<head>
  <title>Ali Lyons Blog</title>
  <meta charset="UTF-8">
  <link rel="stylesheet" type="text/css" href="your-stylesheet-link-here.css">
</head>

<main>
  <h1>Variable Scope in Ruby</h1>
  <h4>09/06/2015</h4>

  <section>
    <p>
    Ruby was created with object oriented best practices in mind. As such,
    it has some built-in constraints that (while mysterious or possibly 
    downright annoying to the noob) help Rubyists create maintainable code. 
    </p>
    <p>
    While tempting for the beginner Rubyist to create variables that are accessible anywhere in the program (global), 
    or to create all instance variables as both readable and write-able regardless of their context or intended use, 
    this would undoubtedly cause rampant unintended side-effects. Good practice dictates objects be encapsulated, 
    which is to say only the most essential information is shared with other programmers, end-users and the rest of 
    the program itself. Details of the specific inner workings are intentionally hidden as a safeguard against
    unintentional modifications.
    </p>
    <p>
    Variable scope in Ruby starts out very tightly restricted, with local variables being only accessible within the 
    method they were created in. Once the method is done running, the variable disappears. Instance variables are 
    available to the entire instance of a class. Class methods are also available across the entire scope of the class
    with a very important caveat: there is only ever one copy of a class variable at one time. As such, class variables
    should be used sparingly or not all. Global variables are extremely scary and best avoided. Their scope is infinite
    and can be altered anywhere within the program. Ruby comes with some built-in global variables that can be quite
    useful, but in general, these are more trouble than they worth.  
    </p>
    <p>
    Following is the syntax for the different Ruby variable types: 
    <!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%">
<span style="color: #888888"># local variable</span>
var
<span style="color: #888888"># instance variable</span>
<span style="color: #3333BB">@var</span>
<span style="color: #888888"># class variable</span>
<span style="color: #336699">@@var</span>
<span style="color: #888888"># global variable</span>
<span style="color: #dd7700; font-weight: bold">$var</span>
</pre></div>  
    </p>

      <!-- copy and paste as many sections as you want to add paragraphs -->
  </section>
</main>


Add tech blog oop concepts
Add tech blog oop concepts
