<commit_before><!DOCTYPE html>

<html>
  <head>
    <title>Presentation</title>

    <meta charset='utf-8'>
    <script src='http://html5slides.googlecode.com/svn/trunk/slides.js'></script>
  </head>
  
  <style>
    /* Your individual styles here, or just use inline styles if that’s
       what you want. */
  </style>

  <body style='display: none'>

    <section class='slides layout-regular template-default'>
      
      <article>
        <h1>
          Learning to Program
          <br>
          with Ruby
        </h1>
        <p>
          <NAME>
          <br>
          @dess_e
        </p>
      </article>
      
      <article>
        <h3>
          Hi, I'm Dessy.
        </h3>
        <p>TODO: Brief intro to myself</p>
        <p>Why I love programming. Why it's an art, and why the audience should get excited about it.</p>
      </article>
      
      <!-- invented it to make it fun, why Ruby is cool and different -->
      <article>
        <h3>
          What is Ruby?
        </h3>
        <p />
        <div class="build">
          <p>Ruby is a programming language.</p>
          <p>Wait ... what's a programming language?</p>
          <p>Let's backtrack a bit.</p>
        </div>
      </article>
      
      <article>
        <div class='statement'>
          There are two things you should know about your computer.
        <div>
      </article>
      
      <article>
        <h3>
          1. Your computer speaks a different language.
        </h3>
        <p>This is how your computer wishes you could speak to it:</p>
        <p />
        <img src="images/machine-language.jpg" width="600" height="411" border="1">
      </article>

      <article>
        <h3>
          This is where a programming language comes in.
        </h3>
        <p>A programming language is a language that is relatively easy for you to learn, but can also be understood by the computer.</p>
        <p>It's the middle ground between English and the language that the computer understands.</p>
      </article>
      
      <article>
        <h3>
          2. Your computer is not very smart. (Sorry.)
        </h3>
        <p>Your computer can only do what you tell it to if you give it exact instructions.</p>
        <p>TODO: Stupid image</p>
      </article>
      
      <article>
        <h3>People vs. Computers</h3>
        <p>
          Suppose you had to teach a person how to make a peanut butter sandwich.
          You might give the person an easy to follow recipe.
        </p>
        <ul>
          <li>Toast two slices of bread</li>
          <li>Spread peanut butter on one slice of bread</li>
          <li>Spread jam on the other slice of bread</li>
          <li>Put the two pieces of bread together</li>
          <li>Put the sandwich on a plate and serve it</li>
        </ul>
      </article>
            
      <article>
        <h3>People understand GENERAL instructions</h3>
        <p>
          We left out some parts of the process, but a person could figure out:
        </p>
        <p>Where to find the ingredients</p>
        <p>To use a butter knife to spread the peanut butter</p>
        <p>To put the bread in a toaster in order to toast it</p>
        <p>etc, etc, etc (there are many little steps)</p>
      </article>
      
      <article>
        <h3>Computers understand EXACT instructions</h3>
        <p>
          This same recipe for a computer would be much, much longer.
        </p>
      </article>
      
      <article>
        <p>Firstly, a computer doesn't know what bread, peanut butter, or jam are, so you would have to define them.</p>
        <p>Once a computer knows what all of the ingredients are, you would have to tell it where to find them.</p>
      </article>
      
      <article>
        <p>
          For instance, you would have to tell it to take the bread off of the counter (after defining a counter!), 
          and if the bread is in a bag (again, defining the bag!), to open the bag first. 
        </p>
        <p>          
          Then you would have to go through the different
          ways that a bag can be sealed: if the bad is twisted, then untwist it; if the bag has a plastic fastener, 
          then take off the fastener; if the bad is tied, then untie it.
        </p>
        <p>You can quickly see how complicated the entire process becomes!</p>
      </article>

      <article>
        <h3>Back to programming languages</h3>
        <p>A programming language makes it easier for you to give the computer instructions.</p>
        <p>
          It's made up of simple elements, and by combining those elements together, 
          a programmer can write a set of instructions that the computer then breaks down and interprets as its own language.
        </p>
      </article>

      <article>
        <h3>
          You've just learned what programming is!
        </h3>
        <p>Programming is writing out exact instructions that your computer can follow to do things.</p>
      </article>
      
      <article>
        <h3>
          Why Ruby Rocks!
        </h3>
        <p>Ruby was created in 1993 by <NAME>, from Japan.</p>
        <p> 
          "I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy. 
          That is the primary purpose of Ruby language." - <NAME>, 2008
        </p>
        <p>That's exactly how the language is known today by developers. Ruby is fun, it's easy to learn, and the syntax is very forgiving.</p>
      </article>
      
      <article>
        <p>This is some code in Java:</p>
        <section>
          <pre>
class Person {
  private String name, int age;

  public void setName(String name) {
    this.name = name;
  }

  public String getName() {
    return name;
  }

  public void setAge(int age) {
    this.age = age;
  }

  public String getAge() {
    return age;
  }
}</pre>
        </section>
      </article>
      
      <article>
        <p>The equivalent code in Ruby looks like this:</p>
        <section>
          <pre>
class Person
  attr_accessor :name, :age
end
          </pre>
        </section>
      </article>

      <article>
        <h3>
          Time to see Ruby in action!
        </h3>
        <p>We're going to open IRB, our Interactive Ruby Shell.</p>
        <p>IRB is like text messaging with Ruby. You type a message to Ruby, and Ruby responds to your message.</p>
        <p>Often you'll be asking Ruby to do something, and it will respond with the result</p>
        <p><b>OS X</b></p>
        <section>
          <pre>Applications -> Utilities -> Terminal</pre>
        </section>
        <p />
        <p><b>Windows</b> (C:\windows\system32\cmd.exe)</p>
        <section>
          <pre>Start -> All Programs -> Accessories -> Command Prompt</pre>
        </section>
      </article>
      
      <article>
        <section class='build'>
          <pre>irb</pre>
          <pre>ruby-1.9.2-p290 :001 > </pre>
          <p>Let's ask Ruby to do something.</p>
        </section>
      </article>
      
      <article>
        <section class='build'>
          <pre>> 1 + 1</pre>
          <pre>=> 2</pre>
          <pre>> 462 * 86</pre>
          <pre>=> 39732</pre>
          <p>Ruby can do math, and it can do it much quicker than a person can.</p>
        </section>
      </article>

      <!-- BIGGER CODE SNIPPETS!!! -->
      <article>
        <section class='build'>
          <pre>> 1 + 2 + 3<br>=> 6</pre>
          <pre>> "ladies" + "learning" + "code"</pre>
          <pre>=> "ladieslearningcode"</pre>
          <p>
            How did Ruby know to add the numbers together, and to concatenate all of the words into one long word?
          </p>
          <p>
            Ruby knows the difference between a number and a word.
          </p>
        </section>
      </article>

      <article>
        <h3>
          Numbers and Words, Integers and Strings
        </h3>
        <p>In Ruby ...</p>
        <p>Numbers without decimals are called integers. We just did some math with some integers.</p>
        <p>Letters, words, and sentences are called strings. We tell Ruby that we are intending to use a string by wrapping it in quotes.</p>
      </article>

      <article>
        <h3>Classes</h3>
        <p>We call Integers and Strings Classes. That's a programming word!</p>
        <p>Classes are like categories.</p>
        <p>We just worked with the String "ladies".</p>
        <p>We say that "ladies" is an <b>instance</b> of the class String.</p>
        <p>In the same way, any other particular word or sentence is an instance of the class String.</p>
        <p>Instances of a class are like nouns in English.</p>
        <p>Let's look at some examples.</p>
      </article>

      <article>
        <h3>SimpsonsCharacter</h3>
        <div style='border:solid 2px black;padding:17px 0px 10px 80px'>
          <img src="images/simpsons.png" width="600" height="411" border="1">
        </div>
        <p>SimpsonsCharacter is the class (category), and <NAME> is the instance (noun) of the class SimpsonsCharacter.</p>
      </article>

      <article>
        <h3>City</h3>
        <div style='border:solid 2px black;padding:17px 0px 10px 80px'>
          <img src="images/toronto.png">
          <img src="images/london.jpg">
          <br>
          <img src="images/new-york.jpg">
          <img src="images/paris.jpg">
        </div>
        <p>City is the class (category), and Toronto is the instance (noun) of the class City.</p>
      </article>

      <article>
        <h3>String</h3>
        <div style='border:solid 2px black;padding:20px'>
          "ladies"<br><br>
          "ladieslearningcode"<br><br>
          "Today you are You, that is truer than true. There is no one alive who is Youer than You."
        </div>
        <p>String is the class (category), and "ladies" is the instance (noun) of the class City.</p>
      </article>

      <article>
        <h3>
          Objects, Objects, Everywhere!
        </h3>
        <p>You've already met Objects. That's another programming word!</p>
        <p>Everything is Ruby is an Object.</p>
        <p>Classes themselves are Objects, and instances of those classes are also Objects.</p>
        <p>The class SimpsonsCharacter is an Object, and Homer Simpson is also an Object.</p>
        <p>The class City is an Object, and Toronto is also an Object.</p>
        <p>The class String is an Object, and "ladies" is also an Object.</p>
      </article>

      <article>
        <h3>
          Playing with Integers
        </h3>
        <section class='build'>
          <pre>> 99.next</pre>
          <pre>=> 100</pre>

          <pre>> 99.odd?</pre>
          <pre>=> true</pre>
          
          <pre>> 99.even?</pre>
          <pre>=> false</pre>
        </section>        
      </article>

      <article>
        <h3>
          Simple String Manipulation
        </h3>
        <section class='build'>
          <pre>> "ladieslearningcode".capitalize</pre>
          <pre>=> "Ladieslearningcode"</pre>

          <pre>> "ladieslearningcode".upcase</pre>
          <pre>=> "LADIESLEARNINGCODE"</pre>

          <pre>> "ladieslearningcode".reverse</pre>
          <pre>=> "edocgninraelseidal"</pre>          
        </section>
      </article>

      <article>
        <h3>
          Methods
        </h3>
        <p>next, odd?, and even? are all methods that you can call on an Integer.</p>
        <p>capitalize, upcase, and reverse are all methods that you can call on a String.</p>
        <p>When you call a method, you're telling the String "ladieslearningcode" to do something.</p>
        <p>Methods are actions. You can compare methods in Ruby to verbs in English.</p>
        <p>In English, you would tell <NAME> to jump. In Ruby, you would call the jump method on Lisa.</p>
      </article>
      
      <!-- long ass llc hash tag -->
      <!-- functions like a nickname -->
      <article>
        <h3>
          I'm lazy! I don't want to do all of this typing!
        </h3>
        <p>When working with the String "ladieslearningcode", it was annoying to have to type it out every single time.</p>
        <p>What if we could type in "ladieslearningcode" just once, and store it in our computer's memory for later use? We can!</p>
        <section><pre>> llc = "ladieslearningcode"<br>=> "ladieslearningcode"</pre></section>
        <p>You've just <b>assigned</b> the String "ladieslearningcode to the <b>variable</b> llc.</p>
        <p>A programmer would say that the variable llc points to the object "ladieslearningcode".</p>
      </article>
      
      <!-- temporary, equals sign means assignment, llc alone just means get it -->
      <!-- explain why .upcase doesn't change the value of the variable itself -->
      <article>
        <h3>
          Variables Can (And Often Do!) Vary
        </h3>
        <p>A variable is called just that because the object it points to can change.</p>
        <section class='build'>
          <pre>> llc = "a lady learning code"</pre><pre>=> "a lady learning code"</pre>
          <div>llc <img src='images/arrow.png'> "a lady learning code"</div>
          <p>Now let's ask for the value of llc.</p>
          <pre>> llc</pre><pre>=> "a lady learning code"</pre>
        </section>
      </article>
      
      <article>
        <p>Let's try some more</p>
        <section class='build'>
          <pre>> llc = 99</pre><pre>=> 99</pre>
          <div>llc <img src='images/arrow.png'> 99</div>
          <p>Let's ask for the value of llc once again.</p>
          <pre>> llc</pre><pre>=> 99</pre>
        </section>
      </article>
      
      <article>
        <h3>The More the Merrier</h3>
        <p>Let's introduce another variable.</p>
        <section class='build'>
          <pre>> copy_cat = llc</pre><pre>=> 99</pre>
          <div>llc <img src='images/arrow.png'> 99 <img src='images/back-arrow.png'> copy_cat</div>
        </section>
      </article>

      <article>
        <p>Let's ask for the value of each variable.</p>
        <section class='build'>
          <pre>> llc</pre><pre>=> 99</pre>
          <pre>> copy_cat</pre><pre>=> 99</pre>
          <p>Now set llc back to "ladieslearningcode"</p>
          <pre>> llc = "ladieslearningcode"</pre><pre>=> "ladieslearningcode"</pre>
        </section>
      </article>
      
      <article>
        <h3>
          String Manipulation With Our Variable
        </h3>
        <p>You can now use this variable exactly like you would have used "ladieslearningcode" before.</p>
        <section>
          <pre>> llc.capitalize</pre>
          <pre>=> "Ladieslearningcode"</pre>

          <pre>> llc.upcase</pre>
          <pre>=> "LADIESLEARNINGCODE"</pre>

          <pre>> llc.reverse</pre>
          <pre>=> "edocgninraelseidal"</pre>
        </section>
      </article>
      
      <article>
        <h3>Modifying the value with a method</h3>
        <p>Try asking for the value of llc now.</p>
        <section class='build'>
          <pre>> llc</pre><pre>=> "ladieslearningcode"</pre>
          <p>But wait, why didn't it change to "edocgninraelseidal"?</p>
          <div>llc <img src='images/arrow.png'> "ladieslearningcode"</div>
          <p>llc is still pointing to "ladieslearningcode". You didn't tell it to point to a different string.</p>
          <p>If you want the value to change, you have to set it to something else.</p>
        </section>
      </article>
      
      <article>
        <section class='build'>
          <pre>> llc = llc.reverse</pre><pre>=> "edocgninraelseidal"</pre>
          <pre>> llc</pre><pre>=> "edocgninraelseidal"</pre>
          <p>If you want the value of a variable to change, you have to explicitly tell it to change.</p>
        </section>
      </article>
      
      <article>
        <h3>
          Let's Try One More
        </h3>
        <pre>> llc.length</pre>
        <pre>=> 18</pre>
        
        <p>
          If you're familiar with Twitter, you're probably starting to get a sense of how Twitter knows 
          how many characters you've typed in.
        </p>
      </article>
      
      <!-- do it in irb first, then have them save it in a program -->
      <!-- no one at Twitter is typing this out for you again, how do they do it? -->
      <article>
        <h3>
          Writing Our First Program
        </h3>
        <p>
          Open any text editor, add the code below, and save it as twitter.rb in your llc directory.
        </p>
        <section>
          <pre>tweet = "I'm writing my first program at the @llcodedotcom<br>Intro to Ruby workshop!"<br>tweet.length</pre>
        </section>
        <p>Type quit to exit from irb, and from the command line, run the following:</p>
        <section>
          <pre>ruby twitter.rb</pre>
        </section>
        <p>Wait, what? Why didn't it show me the length of my string?</p>
      </article>
      
      <article>
        <h3>
          Outputting Text to the Screen
        </h3>
        <p>When you're in irb, you see the <b>return value</b> of each statement you execute.</p>
        <p>In Ruby, every statement you execute returns an object. We'll get back to this shortly when we write our own methods.</p>
        <p>When you're writing a program and running it, you have to explicitly tell the program when you want it to output something.</p>
        <p>Modify your program with the code below, and notice the result when you run it again.</p>
        <section>
          <pre>tweet = "I'm writing my first program at the @llcodedotcom<br>Intro to Ruby workshop!"<br>puts tweet.length</pre>
        </section>
      </article>
      
      <!-- just words, highlight in a different colour before -->
      <article>
        <h3>
          Recap Slide
        </h3>
        <p>TODO: Quick recap of all concepts so far.</p>
      </article>
      
      <!-- tell them to try it in the console, tell mentors to comment the thing -->
      <!-- give them the answer -->
      <article>
        <h3>
          Puzzle One - Variables
        </h3>
        <p>Open puzzle_1.rb in the puzzles folder, and write down the output you expect to see if you were to run this script.</p>
      </article>
      
      <article>
        <h3>
          Getting Input From the User
        </h3>
        <p>The real Twitter asks you to type something, and then tells you how many characters you're working with.</p>
        <p>So far, we've just been putting our tweet directly into the program.</p>
        <p>As a programmer working on developing web applications like Twitter, you very often need to get something from the user.</p>
      </article>
      
      <article>
        <h3>
          Asking for Input
        </h3>
        <p>The <b>puts</b> method is used for output, and the <b>gets</b> method is used for input. Try this:</p>
        <section class='build'>
          <pre>> puts gets<br>Hello? Anyone there?</pre>
          <!-- split these two lines -->
          <pre>Hello? Anyone there?<br>=> nil</pre>
          <p>The gets method "listened" to what you said.</p>
        </section>
      </article>
      
      <!-- you're warning it that you're about to speak, you can type in whatever you want, gets is no longer a command -->
      <!-- reminder that in irb, you always get responses, like in Twitter, but in your program, you have to tell it when you want it to voice its opinion -->
      <article>
        <h3>
          Asking for Input
        </h3>
        <p>Now try this:</p>
        <section class='build'>
          <pre>> tweet = gets<br>I'm a lady learning code with @llcodedotcom #ladieslearningcode</pre>
          <pre>=> "I'm a lady learning code with @llcodedotcom #ladieslearningcode\n"</pre>
          <!-- usually you get something back, but puts has nothing else to do once it's finished, so it gives you back nothing -->
          <pre>> puts tweet<br>I'm a lady learning code with @llcodedotcom #ladieslearningcode<br>=> nil</pre>
        </section>
      </article>
      
       <!-- slide here that says 'WHOA! what's niL? It's nothing, don't worry -->
      
      <article>
        <h3>
          Back to your Twitter Program
        </h3>
        <p>Working with your group, modify your Twitter program to do the following:</p>
        <p>Ask (politely!) for a tweet from the user.</p>
        <p>Output the tweet the user gave.</p>
        <p>Output the number of characters in the tweet.</p>
        <p>Output how many <b>more</b> characters the user can add until they hit 140 characters.</p>
        <p>TODO: Give them sample output</p>
      </article>
      
      <!-- fuck the buttons, tell them twitter -->
      <article>
        <h3>
          Giving Output Based on Input
        </h3>
        <p>
          A lot of a programmer's job, especially when working on web applications, is doing something 
          based on the input the user provided.
        </p>
        <p>
          Twitter, for example, disables the Tweet button if your tweet is over 140 characters, 
          and keeps the button enabled if your tweet is 140 characters or shorter.
        </p>
        <p>
          So far we know how to determine the length of the user's tweet, but we don't know how to tell them 
          whether they can or cannot send their tweet, depending on it's length.
        </p>
      </article>
      
      <article>
        <h3>
          Conditional Logic
        </h3>
        <p>
          Programming is writing out sets of simple instructions for the computer to follow. 
          Let's break down out tweet logic into simple instructions. Here is what we want our program to do:
        </p>
        <p>if the tweet is greater than 140 characters, tell the user that they cannot send their tweet</p>
        <p>if the tweet is less than or equal to 140 characters, tell the user that they can send their tweet</p>
      </article>
      
      <!-- tell them what a valid variable is -->
      <article>
        <h3>
          Conditional Logic: Greater Than
        </h3>
        <p>The mathematical symbol for <b>greater than</b> is <b>></b></p>
        <p>Try the code below in irb (omitting output for now)</p>
        <section class='build'>
          <pre>> 200 > 140</pre>
          <!-- change variable from tweet_length -->
          <pre>> tweet_length = 200<br>> tweet_length > 140</pre>
          <pre>> tweet_length = 80<br>> tweet_length > 140</pre>
        </section>
      </article>
      
      <article>
        <h3>
          Conditional Logic: Less Than
        </h3>
        <p>The mathematical symbol for <b>less than</b> is <b><</b></p>
        <p>Try the code below in irb (omitting output for now)</p>
        <section class='build'>
          <pre>> 5 < 1</pre>
          <!-- "ladieslearningcode".length < 140 -->
          <pre>> tweet_length = 200<br>> tweet_length < 140</pre>
          <pre>> tweet_length = 80<br>> tweet_length < 140</pre>
        </section>
      </article>
      
      <article>
        <h3>
          Conditional Logic in Our Simple Twitter
        </h3>
        <p>
          Let's simplify our if statements from before using our new knowledge.
          Remember that we're storing the user's tweet in the variable tweet.
        </p>
      </article>
      
      <article>
        <h3>
          Conditional Logic in Our Simple Twitter
        </h3>
        <p>Original if statements:</p>
        <p>if the tweet is greater than 140 characters, tell the user that they cannot send their tweet</p>
        <p>if the tweet is less than 140 characters, tell the user that they can send their tweet</p>
        <p />
        <div class='build'>
          <!-- split up, and put actual statement instead of crap code -->
          <p>if tweet.length > 140 puts "Your tweet is too long!"</p>
          <p>if tweet.length < 140 puts "Tweet your heart out!"</p>
        </div>
      </article>
      
      <article>
        <h3>
          Try it out!
        </h3>
        <p>Replace the puts statements in your Twitter script with the code below.</p>
        <section>
          <pre>if tweet.length > 140<br>  puts "Your tweet is too long!"<br>end<br><br>if tweet.length < 140<br>  puts "Tweet your heart out!"<br>end</pre>
        </section>
        <p>
          Using the tweets from tweets.txt, try out your new script! 
          What's the problem here? What do you notice happened when using the tweets in tweets.txt?
        </p>
      </article>

      <article>
        <h3>
          Your First Bug!
        </h3>
        <p>This is really a bug, since we're not actually taking into account all possible tweet lengths.</p>
        <p>Most programming problems can be solved many different ways, and this bug is no exception.</p>
        <p>
          We're going to look at three different solutions, and learn more about if statements as 
          well as comparing objects along the way.
        </p>
      </article>

      <article>
        <h3>
          First (Worst) Solution
        </h3>
        <p>Since we're only missing one case, the case where the tweet is exactly 140 characters, we can just add another if statement.</p>
        <p>Add this last if statement to the bottom of your file:</p>
        <section>
          <pre>if tweet.length == 140<br>  puts "Tweet your heart out!"<br>end</pre>
        </section>
        <p>
          The == operator checks that the value of the objects on either side of it are equal. 
          Run your script again and notice that it catches the last case where a tweet is 140 characters long.
        </p>
      </article>
      
      <!-- evaluated in order, the first one wins -->
      <article>
        <h3>
          Refactoring Our Code
        </h3>
        <p>
          Programmers are always refactoring (re-strcturing, re-organizing) their code to make it cleaner and more readable.
          Right now is a great time to do that. 
        </p>
        <p>Three if statements are unnecessary. We can actually combine all of these if statements into one, like so:</p>
        <section>
          <pre>if tweet.length > 140<br>  puts "Your tweet is too long!"<br>elsif tweet.length < 140<br>  puts "Tweet your heart out!"<br>elsif tweet.length == 140<br>  puts "Tweet your heart out!"<br>end</pre>
        </section>
        <p>
          If the first if doesn't evaluate to true, then the next one is attempted, and so on.
          TODO: Talk about the details of this. 
        </p>
      </article>
      
      <article>
        <h3>
          Second Solution
        </h3>
        <p>
          Our code is already better (and still has no bugs), but more refactoring can be done.
          Notice that the line puts "Tweet your hear out!" is repeated? This is unnecessary. 
          Let's cut it out by replace the entire if statement with the code below:
        </p>
        <section>
          <pre>if tweet.length > 140<br>  puts "Your tweet is too long!"<br>elsif tweet.length <= 140<br>  puts "Tweet your heart out!"<br>end</pre>
        </section>
        <p>The <= operator behaves the exact same way as the less than operator, but checks for equality as well.</p>
        <p>As you may have guessed, checking for equality with greater than works exactly the same way, using the >= operator.</p>
      </article>
      
      <article>
        <h3>
          Third Time's a Charm
        </h3>
        <p>
          This is better, but look at the logic closely. Do we really even need to specify the second condition?
          Can't we just prevent the user from tweeting is their tweet is over 140 characters, and let them tweet in all other cases?
        </p>
        <p>Yes we can! Replace your code again with the code below:</p>
        <section>
          <pre>if tweet.length > 140<br>  puts "Your tweet is too long!"<br>else<br>  puts "Tweet your heart out!"<br>end</pre>
        </section>
        <p>Run your code again, and it should function the exact same way!</p>        
      </article>
      
      <!-- slide with all of the operators that they can goof around with, stop for a bit and play around -->
      <!-- cheat sheet of this is a keyword, this is a variable, etc. etc. -->
      
      <article>
        <h3>
          Recap Slide
        </h3>
        <p>TODO: Recap of I/O and conditionals</p>
      </article>
      
      <!-- tell them the ideal solution, how many lines should they shorten it to -->
      <article>
        <h3>
          Puzzle Two - Conditionals
        </h3>
        <p>
          Look at the program in puzzle_2.rb. The program asks the user for the month of their birthday, 
          and then outputs a message about the season the user celebrates their birthday in. 
        </p>
        <p>Which months does this program consider to be spring, summer, winter, and fall?</p>
        <p>
          Can you simplify the logic to make the program as few lines of code as possible? 
          Try simplifying the program one step at a time, and run it each time to make sure it behaves like you expect it to.
        </p>
      </article>
      
      <!-- each puzzle, challenge, etc. is a recipe with ingredients -->
      
      <article>
        <h3>
          Loopy
        </h3>
        <p>
          What if you want to be able to tell your program when to stop running? Create a new program with the following code:
        </p>
        <section>
          <pre>TODO: Code form loop_1.rb</pre>
        </section>
        <p>TODO: Explain chomp, explain looping</p>
      </article>
      
      <article>
        <h3>
          What if we know how many times the program needs to do that same thing?
        </h3>
        <p>
          Again, there are several ways to do this
        </p>
        <section>
          <pre>TODO: Code form loop_2.rb, code form loop_3.rb, loop_4.rb, loop_5.rb</pre>
        </section>
        <p>TODO: Explain outputting a variable within a string</p>
        <p>TODO: Avoid showing loop_4.rb and challenge them to do it themselves?</p>
      </article>
      
      <article>
        <h3>
          What if we don't want to count, but we have a set of something else we want to loop over?
        </h3>
        <p>Look again at loop_5.rb, example of an array</p>
        <p>TODO: Explain arrays - a collection of any object</p>
        <section>
          <pre>TODO: Code form loop_6.rb</pre>
        </section>
      </article>
      
      <article>
        <h3>
          There are many methods on Array, as well
        </h3>
        <p>TODO: Examples of array methods</p>
        <p>join, delete_at, [], <<</p>
      </article>
      
      <article>
        <h3>
          Puzzle 3 - Arrays
        </h3>
        <p>What will be the output of puzzle 3?</p>
      </article>
      
      <article>
        <h3>
          Challenge
        </h3>
        <p>TODO: Challenge them to write the code in loop_6.rb</p>
      </article>
      
      <article>
        <h3>
          Blackjack Game
        </h3>
        <p>TODO: Either look at game and go over each part</p>
        <p>OR give them the game as a challenge, and walk them through the steps</p>
        <p>Use blackjack_1.rb vs. blackjack_2.rb to teach them methods</p>
      </article>
      
    </section>

  </body>
</html><commit_msg>Twitter intro enhancements<commit_after><!DOCTYPE html>

<html>
  <head>
    <title>Presentation</title>

    <meta charset='utf-8'>
    <script src='http://html5slides.googlecode.com/svn/trunk/slides.js'></script>
  </head>
  
  <style>
    /* Your individual styles here, or just use inline styles if that’s
       what you want. */
  </style>

  <body style='display: none'>

    <section class='slides layout-regular template-default'>
      
      <article>
        <h1>
          Learning to Program
          <br>
          with Ruby
        </h1>
        <p>
          <NAME>
          <br>
          @dess_e
        </p>
      </article>
      
      <article>
        <h3>
          Hi, I'm Dessy.
        </h3>
        <p>TODO: Brief intro to myself</p>
        <p>Why I love programming. Why it's an art, and why the audience should get excited about it.</p>
      </article>
      
      <!-- invented it to make it fun, why Ruby is cool and different -->
      <article>
        <h3>
          What is Ruby?
        </h3>
        <p />
        <div class="build">
          <p>Ruby is a programming language.</p>
          <p>Wait ... what's a programming language?</p>
          <p>Let's backtrack a bit.</p>
        </div>
      </article>
      
      <article>
        <div class='statement'>
          There are two things you should know about your computer.
        <div>
      </article>
      
      <article>
        <h3>
          1. Your computer speaks a different language.
        </h3>
        <p>This is how your computer wishes you could speak to it:</p>
        <p />
        <img src="images/machine-language.jpg" width="600" height="411" border="1">
      </article>

      <article>
        <h3>
          This is where a programming language comes in.
        </h3>
        <p>A programming language is a language that is relatively easy for you to learn, but can also be understood by the computer.</p>
        <p>It's the middle ground between English and the language that the computer understands.</p>
      </article>
      
      <article>
        <h3>
          2. Your computer is not very smart. (Sorry.)
        </h3>
        <p>Your computer can only do what you tell it to if you give it exact instructions.</p>
        <p>TODO: Stupid image</p>
      </article>
      
      <article>
        <h3>People vs. Computers</h3>
        <p>
          Suppose you had to teach a person how to make a peanut butter sandwich.
          You might give the person an easy to follow recipe.
        </p>
        <ul>
          <li>Toast two slices of bread</li>
          <li>Spread peanut butter on one slice of bread</li>
          <li>Spread jam on the other slice of bread</li>
          <li>Put the two pieces of bread together</li>
          <li>Put the sandwich on a plate and serve it</li>
        </ul>
      </article>
            
      <article>
        <h3>People understand GENERAL instructions</h3>
        <p>
          We left out some parts of the process, but a person could figure out:
        </p>
        <p>Where to find the ingredients</p>
        <p>To use a butter knife to spread the peanut butter</p>
        <p>To put the bread in a toaster in order to toast it</p>
        <p>etc, etc, etc (there are many little steps)</p>
      </article>
      
      <article>
        <h3>Computers understand EXACT instructions</h3>
        <p>
          This same recipe for a computer would be much, much longer.
        </p>
      </article>
      
      <article>
        <p>Firstly, a computer doesn't know what bread, peanut butter, or jam are, so you would have to define them.</p>
        <p>Once a computer knows what all of the ingredients are, you would have to tell it where to find them.</p>
      </article>
      
      <article>
        <p>
          For instance, you would have to tell it to take the bread off of the counter (after defining a counter!), 
          and if the bread is in a bag (again, defining the bag!), to open the bag first. 
        </p>
        <p>          
          Then you would have to go through the different
          ways that a bag can be sealed: if the bad is twisted, then untwist it; if the bag has a plastic fastener, 
          then take off the fastener; if the bad is tied, then untie it.
        </p>
        <p>You can quickly see how complicated the entire process becomes!</p>
      </article>

      <article>
        <h3>Back to programming languages</h3>
        <p>A programming language makes it easier for you to give the computer instructions.</p>
        <p>
          It's made up of simple elements, and by combining those elements together, 
          a programmer can write a set of instructions that the computer then breaks down and interprets as its own language.
        </p>
      </article>

      <article>
        <h3>
          You've just learned what programming is!
        </h3>
        <p>Programming is writing out exact instructions that your computer can follow to do things.</p>
      </article>
      
      <article>
        <h3>
          Why Ruby Rocks!
        </h3>
        <p>Ruby was created in 1993 by <NAME>, from Japan.</p>
        <p> 
          "I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy. 
          That is the primary purpose of Ruby language." - <NAME>, 2008
        </p>
        <p>That's exactly how the language is known today by developers. Ruby is fun, it's easy to learn, and the syntax is very forgiving.</p>
      </article>
      
      <article>
        <p>This is some code in Java:</p>
        <section>
          <pre>
class Person {
  private String name, int age;

  public void setName(String name) {
    this.name = name;
  }

  public String getName() {
    return name;
  }

  public void setAge(int age) {
    this.age = age;
  }

  public String getAge() {
    return age;
  }
}</pre>
        </section>
      </article>
      
      <article>
        <p>The equivalent code in Ruby looks like this:</p>
        <section>
          <pre>
class Person
  attr_accessor :name, :age
end
          </pre>
        </section>
      </article>

      <article>
        <h3>
          Time to see Ruby in action!
        </h3>
        <p>We're going to open IRB, our Interactive Ruby Shell.</p>
        <p>IRB is like text messaging with Ruby. You type a message to Ruby, and Ruby responds to your message.</p>
        <p>Often you'll be asking Ruby to do something, and it will respond with the result</p>
        <p><b>OS X</b></p>
        <section>
          <pre>Applications -> Utilities -> Terminal</pre>
        </section>
        <p />
        <p><b>Windows</b> (C:\windows\system32\cmd.exe)</p>
        <section>
          <pre>Start -> All Programs -> Accessories -> Command Prompt</pre>
        </section>
      </article>
      
      <article>
        <section class='build'>
          <pre>irb</pre>
          <pre>ruby-1.9.2-p290 :001 > </pre>
          <p>Let's ask Ruby to do something.</p>
        </section>
      </article>
      
      <article>
        <section class='build'>
          <pre>> 1 + 1</pre>
          <pre>=> 2</pre>
          <pre>> 462 * 86</pre>
          <pre>=> 39732</pre>
          <p>Ruby can do math, and it can do it much quicker than a person can.</p>
        </section>
      </article>

      <!-- BIGGER CODE SNIPPETS!!! -->
      <article>
        <section class='build'>
          <pre>> 1 + 2 + 3<br>=> 6</pre>
          <pre>> "ladies" + "learning" + "code"</pre>
          <pre>=> "ladieslearningcode"</pre>
          <p>
            How did Ruby know to add the numbers together, and to concatenate all of the words into one long word?
          </p>
          <p>
            Ruby knows the difference between a number and a word.
          </p>
        </section>
      </article>

      <article>
        <h3>
          Numbers and Words, Integers and Strings
        </h3>
        <p>In Ruby ...</p>
        <p>Numbers without decimals are called integers. We just did some math with some integers.</p>
        <p>Letters, words, and sentences are called strings. We tell Ruby that we are intending to use a string by wrapping it in quotes.</p>
      </article>

      <article>
        <h3>Classes</h3>
        <p>We call Integers and Strings Classes. That's a programming word!</p>
        <p>Classes are like categories.</p>
        <p>We just worked with the String "ladies".</p>
        <p>We say that "ladies" is an <b>instance</b> of the class String.</p>
        <p>In the same way, any other particular word or sentence is an instance of the class String.</p>
        <p>Instances of a class are like nouns in English.</p>
        <p>Let's look at some examples.</p>
      </article>

      <article>
        <h3>SimpsonsCharacter</h3>
        <div style='border:solid 2px black;padding:17px 0px 10px 80px'>
          <img src="images/simpsons.png" width="600" height="411" border="1">
        </div>
        <p>SimpsonsCharacter is the class (category), and <NAME> is the instance (noun) of the class SimpsonsCharacter.</p>
      </article>

      <article>
        <h3>City</h3>
        <div style='border:solid 2px black;padding:17px 0px 10px 80px'>
          <img src="images/toronto.png">
          <img src="images/london.jpg">
          <br>
          <img src="images/new-york.jpg">
          <img src="images/paris.jpg">
        </div>
        <p>City is the class (category), and Toronto is the instance (noun) of the class City.</p>
      </article>

      <article>
        <h3>String</h3>
        <div style='border:solid 2px black;padding:20px'>
          "ladies"<br><br>
          "ladieslearningcode"<br><br>
          "Today you are You, that is truer than true. There is no one alive who is Youer than You."
        </div>
        <p>String is the class (category), and "ladies" is the instance (noun) of the class City.</p>
      </article>

      <article>
        <h3>
          Objects, Objects, Everywhere!
        </h3>
        <p>You've already met Objects. That's another programming word!</p>
        <p>Everything is Ruby is an Object.</p>
        <p>Classes themselves are Objects, and instances of those classes are also Objects.</p>
        <p>The class SimpsonsCharacter is an Object, and Homer Simpson is also an Object.</p>
        <p>The class City is an Object, and Toronto is also an Object.</p>
        <p>The class String is an Object, and "ladies" is also an Object.</p>
      </article>

      <article>
        <h3>
          Playing with Integers
        </h3>
        <section class='build'>
          <pre>> 99.next</pre>
          <pre>=> 100</pre>

          <pre>> 99.odd?</pre>
          <pre>=> true</pre>
          
          <pre>> 99.even?</pre>
          <pre>=> false</pre>
        </section>        
      </article>

      <article>
        <h3>
          Simple String Manipulation
        </h3>
        <section class='build'>
          <pre>> "ladieslearningcode".capitalize</pre>
          <pre>=> "Ladieslearningcode"</pre>

          <pre>> "ladieslearningcode".upcase</pre>
          <pre>=> "LADIESLEARNINGCODE"</pre>

          <pre>> "ladieslearningcode".reverse</pre>
          <pre>=> "edocgninraelseidal"</pre>          
        </section>
      </article>

      <article>
        <h3>
          Methods
        </h3>
        <p>next, odd?, and even? are all methods that you can call on an Integer.</p>
        <p>capitalize, upcase, and reverse are all methods that you can call on a String.</p>
        <p>When you call a method, you're telling the String "ladieslearningcode" to do something.</p>
        <p>Methods are actions. You can compare methods in Ruby to verbs in English.</p>
        <p>In English, you would tell <NAME>son to jump. In Ruby, you would call the jump method on Lisa.</p>
      </article>
      
      <!-- long ass llc hash tag -->
      <!-- functions like a nickname -->
      <article>
        <h3>
          I'm lazy! I don't want to do all of this typing!
        </h3>
        <p>When working with the String "ladieslearningcode", it was annoying to have to type it out every single time.</p>
        <p>What if we could type in "ladieslearningcode" just once, and store it in our computer's memory for later use? We can!</p>
        <section><pre>> llc = "ladieslearningcode"<br>=> "ladieslearningcode"</pre></section>
        <p>You've just <b>assigned</b> the String "ladieslearningcode to the <b>variable</b> llc.</p>
        <p>A programmer would say that the variable llc points to the object "ladieslearningcode".</p>
      </article>
      
      <!-- temporary, equals sign means assignment, llc alone just means get it -->
      <!-- explain why .upcase doesn't change the value of the variable itself -->
      <article>
        <h3>
          Variables Can (And Often Do!) Vary
        </h3>
        <p>A variable is called just that because the object it points to can change.</p>
        <section class='build'>
          <pre>> llc = "a lady learning code"</pre><pre>=> "a lady learning code"</pre>
          <div>llc <img src='images/arrow.png'> "a lady learning code"</div>
          <p>Now let's ask for the value of llc.</p>
          <pre>> llc</pre><pre>=> "a lady learning code"</pre>
        </section>
      </article>
      
      <article>
        <p>Let's try some more</p>
        <section class='build'>
          <pre>> llc = 99</pre><pre>=> 99</pre>
          <div>llc <img src='images/arrow.png'> 99</div>
          <p>Let's ask for the value of llc once again.</p>
          <pre>> llc</pre><pre>=> 99</pre>
        </section>
      </article>
      
      <article>
        <h3>The More the Merrier</h3>
        <p>Let's introduce another variable.</p>
        <section class='build'>
          <pre>> copy_cat = llc</pre><pre>=> 99</pre>
          <div>llc <img src='images/arrow.png'> 99 <img src='images/back-arrow.png'> copy_cat</div>
        </section>
      </article>

      <article>
        <p>Let's ask for the value of each variable.</p>
        <section class='build'>
          <pre>> llc</pre><pre>=> 99</pre>
          <pre>> copy_cat</pre><pre>=> 99</pre>
          <p>Now set llc back to "ladieslearningcode"</p>
          <pre>> llc = "ladieslearningcode"</pre><pre>=> "ladieslearningcode"</pre>
        </section>
      </article>
      
      <article>
        <h3>
          String Manipulation With Our Variable
        </h3>
        <p>You can now use this variable exactly like you would have used "ladieslearningcode" before.</p>
        <section>
          <pre>> llc.capitalize</pre>
          <pre>=> "Ladieslearningcode"</pre>

          <pre>> llc.upcase</pre>
          <pre>=> "LADIESLEARNINGCODE"</pre>

          <pre>> llc.reverse</pre>
          <pre>=> "edocgninraelseidal"</pre>
        </section>
      </article>
      
      <article>
        <h3>Modifying the value with a method</h3>
        <p>Try asking for the value of llc now.</p>
        <section class='build'>
          <pre>> llc</pre><pre>=> "ladieslearningcode"</pre>
          <p>But wait, why didn't it change to "edocgninraelseidal"?</p>
          <div>llc <img src='images/arrow.png'> "ladieslearningcode"</div>
          <p>llc is still pointing to "ladieslearningcode". You didn't tell it to point to a different string.</p>
          <p>If you want the value to change, you have to set it to something else.</p>
        </section>
      </article>
      
      <article>
        <section class='build'>
          <pre>> llc = llc.reverse</pre><pre>=> "edocgninraelseidal"</pre>
          <pre>> llc</pre><pre>=> "edocgninraelseidal"</pre>
          <p>If you want the value of a variable to change, you have to explicitly tell it to change.</p>
        </section>
      </article>
      
      <article>
        <h3>
          Let's Try One More
        </h3>
        <pre>> llc.length</pre>
        <pre>=> 18</pre>
        
        <p>
          If you're familiar with Twitter, you're probably starting to get a sense of how Twitter knows 
          how many characters you've typed in.
        </p>
      </article>
      
      <article>
        <p>Let's write and manipulate a few tweets</p>
        <section class='build'>
          <pre>> tweet = "I'm writing my first program at the @llcodedotcom<br>Intro to Ruby workshop!"</pre>
          <pre>=> "I'm writing my first program at the @llcodedotcom <br>Intro to Ruby workshop!"</pre>
          <pre>> tweet.length</pre>
          <pre>=> 73</pre>
          <p>
            So far we've been working only in IRB, but our code is getting more complicated and we 
            want to be able to run it again without having to type it all out. We want to save our code 
            somewhere so that we can run it again and again. This is called a program.
          </p>
        </section>
      </article>
      
      <article>
        <h3>
          Writing Our First Program
        </h3>
        <p>
          Open any text editor, add the same code, and save it as twitter.rb in your llc directory.
        </p>
        <section>
          <pre>tweet = "I'm writing my first program at the @llcodedotcom<br>Intro to Ruby workshop!"<br>tweet.length</pre>
        </section>
        <p>To run your program, type <b>quit</b> to exit from IRB, and then type:</p>
        <section>
          <pre>ruby twitter.rb</pre>
        </section>
        <p>Wait, what? Why didn't it show me the length of my string?</p>
      </article>
      
      <article>
        <h3>
          Outputting Text to the Screen
        </h3>
        <p>
          In IRB, we were used to seeing the return value of every statement we executed. 
          Remember, IRB is like back and forth text messaging.
        </p>
        <p>
          When you're writing a program and running it, you have to explicitly tell the program when you want it to output something.
        </p>
        <p>Modify your program with the code below, and notice the result when you run it again.</p>
        <section>
          <pre>tweet = "I'm writing my first program at the @llcodedotcom<br>Intro to Ruby workshop!"<br>puts tweet.length</pre>
        </section>
      </article>
      
      <!-- just words, highlight in a different colour before -->
      <article>
        <h3>
          Recap Slide
        </h3>
        <p>Integer</p>
        <p>String</p>
        <p>Class</p>
        <p>Object</p>
        <p>Variable</p>
      </article>
      
      <!-- tell them to try it in the console, tell mentors to comment the thing -->
      <!-- give them the answer -->
      <article>
        <h3>
          Puzzle One - Variables
        </h3>
        <p>Open puzzle_1.rb in the puzzles folder, and write down the output you expect to see if you were to run this script.</p>
      </article>
      
      <article>
        <h3>
          Getting Input From the User
        </h3>
        <p>The real Twitter asks you to type something, and then tells you how many characters you're working with.</p>
        <p>So far, we've just been putting our tweet directly into the program.</p>
        <p>As a programmer working on developing web applications like Twitter, you very often need to get something from the user.</p>
      </article>
      
      <article>
        <h3>
          Asking for Input
        </h3>
        <p>The <b>puts</b> method is used for output, and the <b>gets</b> method is used for input. Try this:</p>
        <section class='build'>
          <pre>> puts gets<br>Hello? Anyone there?</pre>
          <!-- split these two lines -->
          <pre>Hello? Anyone there?<br>=> nil</pre>
          <p>The gets method "listened" to what you said.</p>
        </section>
      </article>
      
      <!-- you're warning it that you're about to speak, you can type in whatever you want, gets is no longer a command -->
      <!-- reminder that in irb, you always get responses, like in Twitter, but in your program, you have to tell it when you want it to voice its opinion -->
      <article>
        <h3>
          Asking for Input
        </h3>
        <p>Now try this:</p>
        <section class='build'>
          <pre>> tweet = gets<br>I'm a lady learning code with @llcodedotcom #ladieslearningcode</pre>
          <pre>=> "I'm a lady learning code with @llcodedotcom #ladieslearningcode\n"</pre>
          <!-- usually you get something back, but puts has nothing else to do once it's finished, so it gives you back nothing -->
          <pre>> puts tweet<br>I'm a lady learning code with @llcodedotcom #ladieslearningcode<br>=> nil</pre>
        </section>
      </article>
      
       <!-- slide here that says 'WHOA! what's niL? It's nothing, don't worry -->
      
      <article>
        <h3>
          Back to your Twitter Program
        </h3>
        <p>Working with your group, modify your Twitter program to do the following:</p>
        <p>Ask (politely!) for a tweet from the user.</p>
        <p>Output the tweet the user gave.</p>
        <p>Output the number of characters in the tweet.</p>
        <p>Output how many <b>more</b> characters the user can add until they hit 140 characters.</p>
        <p>TODO: Give them sample output</p>
      </article>
      
      <!-- fuck the buttons, tell them twitter -->
      <article>
        <h3>
          Giving Output Based on Input
        </h3>
        <p>
          A lot of a programmer's job, especially when working on web applications, is doing something 
          based on the input the user provided.
        </p>
        <p>
          Twitter, for example, disables the Tweet button if your tweet is over 140 characters, 
          and keeps the button enabled if your tweet is 140 characters or shorter.
        </p>
        <p>
          So far we know how to determine the length of the user's tweet, but we don't know how to tell them 
          whether they can or cannot send their tweet, depending on it's length.
        </p>
      </article>
      
      <article>
        <h3>
          Conditional Logic
        </h3>
        <p>
          Programming is writing out sets of simple instructions for the computer to follow. 
          Let's break down out tweet logic into simple instructions. Here is what we want our program to do:
        </p>
        <p>if the tweet is greater than 140 characters, tell the user that they cannot send their tweet</p>
        <p>if the tweet is less than or equal to 140 characters, tell the user that they can send their tweet</p>
      </article>
      
      <!-- tell them what a valid variable is -->
      <article>
        <h3>
          Conditional Logic: Greater Than
        </h3>
        <p>The mathematical symbol for <b>greater than</b> is <b>></b></p>
        <p>Try the code below in irb (omitting output for now)</p>
        <section class='build'>
          <pre>> 200 > 140</pre>
          <!-- change variable from tweet_length -->
          <pre>> tweet_length = 200<br>> tweet_length > 140</pre>
          <pre>> tweet_length = 80<br>> tweet_length > 140</pre>
        </section>
      </article>
      
      <article>
        <h3>
          Conditional Logic: Less Than
        </h3>
        <p>The mathematical symbol for <b>less than</b> is <b><</b></p>
        <p>Try the code below in irb (omitting output for now)</p>
        <section class='build'>
          <pre>> 5 < 1</pre>
          <!-- "ladieslearningcode".length < 140 -->
          <pre>> tweet_length = 200<br>> tweet_length < 140</pre>
          <pre>> tweet_length = 80<br>> tweet_length < 140</pre>
        </section>
      </article>
      
      <article>
        <h3>
          Conditional Logic in Our Simple Twitter
        </h3>
        <p>
          Let's simplify our if statements from before using our new knowledge.
          Remember that we're storing the user's tweet in the variable tweet.
        </p>
      </article>
      
      <article>
        <h3>
          Conditional Logic in Our Simple Twitter
        </h3>
        <p>Original if statements:</p>
        <p>if the tweet is greater than 140 characters, tell the user that they cannot send their tweet</p>
        <p>if the tweet is less than 140 characters, tell the user that they can send their tweet</p>
        <p />
        <div class='build'>
          <!-- split up, and put actual statement instead of crap code -->
          <p>if tweet.length > 140 puts "Your tweet is too long!"</p>
          <p>if tweet.length < 140 puts "Tweet your heart out!"</p>
        </div>
      </article>
      
      <article>
        <h3>
          Try it out!
        </h3>
        <p>Replace the puts statements in your Twitter script with the code below.</p>
        <section>
          <pre>if tweet.length > 140<br>  puts "Your tweet is too long!"<br>end<br><br>if tweet.length < 140<br>  puts "Tweet your heart out!"<br>end</pre>
        </section>
        <p>
          Using the tweets from tweets.txt, try out your new script! 
          What's the problem here? What do you notice happened when using the tweets in tweets.txt?
        </p>
      </article>

      <article>
        <h3>
          Your First Bug!
        </h3>
        <p>This is really a bug, since we're not actually taking into account all possible tweet lengths.</p>
        <p>Most programming problems can be solved many different ways, and this bug is no exception.</p>
        <p>
          We're going to look at three different solutions, and learn more about if statements as 
          well as comparing objects along the way.
        </p>
      </article>

      <article>
        <h3>
          First (Worst) Solution
        </h3>
        <p>Since we're only missing one case, the case where the tweet is exactly 140 characters, we can just add another if statement.</p>
        <p>Add this last if statement to the bottom of your file:</p>
        <section>
          <pre>if tweet.length == 140<br>  puts "Tweet your heart out!"<br>end</pre>
        </section>
        <p>
          The == operator checks that the value of the objects on either side of it are equal. 
          Run your script again and notice that it catches the last case where a tweet is 140 characters long.
        </p>
      </article>
      
      <!-- evaluated in order, the first one wins -->
      <article>
        <h3>
          Refactoring Our Code
        </h3>
        <p>
          Programmers are always refactoring (re-strcturing, re-organizing) their code to make it cleaner and more readable.
          Right now is a great time to do that. 
        </p>
        <p>Three if statements are unnecessary. We can actually combine all of these if statements into one, like so:</p>
        <section>
          <pre>if tweet.length > 140<br>  puts "Your tweet is too long!"<br>elsif tweet.length < 140<br>  puts "Tweet your heart out!"<br>elsif tweet.length == 140<br>  puts "Tweet your heart out!"<br>end</pre>
        </section>
        <p>
          If the first if doesn't evaluate to true, then the next one is attempted, and so on.
          TODO: Talk about the details of this. 
        </p>
      </article>
      
      <article>
        <h3>
          Second Solution
        </h3>
        <p>
          Our code is already better (and still has no bugs), but more refactoring can be done.
          Notice that the line puts "Tweet your hear out!" is repeated? This is unnecessary. 
          Let's cut it out by replace the entire if statement with the code below:
        </p>
        <section>
          <pre>if tweet.length > 140<br>  puts "Your tweet is too long!"<br>elsif tweet.length <= 140<br>  puts "Tweet your heart out!"<br>end</pre>
        </section>
        <p>The <= operator behaves the exact same way as the less than operator, but checks for equality as well.</p>
        <p>As you may have guessed, checking for equality with greater than works exactly the same way, using the >= operator.</p>
      </article>
      
      <article>
        <h3>
          Third Time's a Charm
        </h3>
        <p>
          This is better, but look at the logic closely. Do we really even need to specify the second condition?
          Can't we just prevent the user from tweeting is their tweet is over 140 characters, and let them tweet in all other cases?
        </p>
        <p>Yes we can! Replace your code again with the code below:</p>
        <section>
          <pre>if tweet.length > 140<br>  puts "Your tweet is too long!"<br>else<br>  puts "Tweet your heart out!"<br>end</pre>
        </section>
        <p>Run your code again, and it should function the exact same way!</p>        
      </article>
      
      <!-- slide with all of the operators that they can goof around with, stop for a bit and play around -->
      <!-- cheat sheet of this is a keyword, this is a variable, etc. etc. -->
      
      <article>
        <h3>
          Recap Slide
        </h3>
        <p>TODO: Recap of I/O and conditionals</p>
      </article>
      
      <!-- tell them the ideal solution, how many lines should they shorten it to -->
      <article>
        <h3>
          Puzzle Two - Conditionals
        </h3>
        <p>
          Look at the program in puzzle_2.rb. The program asks the user for the month of their birthday, 
          and then outputs a message about the season the user celebrates their birthday in. 
        </p>
        <p>Which months does this program consider to be spring, summer, winter, and fall?</p>
        <p>
          Can you simplify the logic to make the program as few lines of code as possible? 
          Try simplifying the program one step at a time, and run it each time to make sure it behaves like you expect it to.
        </p>
      </article>
      
      <!-- each puzzle, challenge, etc. is a recipe with ingredients -->
      
      <article>
        <h3>
          Loopy
        </h3>
        <p>
          What if you want to be able to tell your program when to stop running? Create a new program with the following code:
        </p>
        <section>
          <pre>TODO: Code form loop_1.rb</pre>
        </section>
        <p>TODO: Explain chomp, explain looping</p>
      </article>
      
      <article>
        <h3>
          What if we know how many times the program needs to do that same thing?
        </h3>
        <p>
          Again, there are several ways to do this
        </p>
        <section>
          <pre>TODO: Code form loop_2.rb, code form loop_3.rb, loop_4.rb, loop_5.rb</pre>
        </section>
        <p>TODO: Explain outputting a variable within a string</p>
        <p>TODO: Avoid showing loop_4.rb and challenge them to do it themselves?</p>
      </article>
      
      <article>
        <h3>
          What if we don't want to count, but we have a set of something else we want to loop over?
        </h3>
        <p>Look again at loop_5.rb, example of an array</p>
        <p>TODO: Explain arrays - a collection of any object</p>
        <section>
          <pre>TODO: Code form loop_6.rb</pre>
        </section>
      </article>
      
      <article>
        <h3>
          There are many methods on Array, as well
        </h3>
        <p>TODO: Examples of array methods</p>
        <p>join, delete_at, [], <<</p>
      </article>
      
      <article>
        <h3>
          Puzzle 3 - Arrays
        </h3>
        <p>What will be the output of puzzle 3?</p>
      </article>
      
      <article>
        <h3>
          Challenge
        </h3>
        <p>TODO: Challenge them to write the code in loop_6.rb</p>
      </article>
      
      <article>
        <h3>
          Blackjack Game
        </h3>
        <p>TODO: Either look at game and go over each part</p>
        <p>OR give them the game as a challenge, and walk them through the steps</p>
        <p>Use blackjack_1.rb vs. blackjack_2.rb to teach them methods</p>
      </article>
      
    </section>

  </body>
</html>
{'fraction_non_alphanumeric': 0.11127240595809139, 'fraction_numerical': 0.01028780610956829, 'mean_word_length': 1.8651446654611212, 'pattern_counts': {'":': 0, '<': 1933, '<?xml version=': 0, '>': 2081, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 4, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4172814', 'n_tokens_mistral': 19156, 'n_tokens_neox': 18190, 'n_words': 7264}