strings.step

goals do
  goal "Understand when to use strings"
  goal "Learn how to combine strings"
  goal "Learn about string interpolation"
end

step do
  irb <<IRB
'a string in single quotes'
"a string in double quotes"
IRB
  message 'A string is a series of characters. Strings can be created using either single or double quotes.'
  message 'These strings weren\'t saved into a variable. What happens to data not saved into a variable?'
  message 'What happens if you start a string with one kind of quote and end with another? How can you fix it?'
end

step do
  irb <<IRB
'Hello, ' + 'Jane'
'apples' * 3
IRB
  message 'Strings can be added to each other or multipled by numbers. What does this do?'
end

step do
  irb <<'IRB'
name = 'Jane'
"Hello #{name}"
IRB
  message '(the `{}` characters are generally called **curly braces**)'
  message 'This is called string interpolation. String interpolation lets you embed a ruby statement in another string. It only works with double quotes: what happens when you try the same thing with single quotes?'
    irb <<'IRB'
"Two plus two is #{2 + 2}"
IRB
  message 'The code in the curly braces can be any valid ruby statement. Try putting various things in the curly brackets to see what works and what doesn\'t.'
end

step do
  irb <<-IRB
'I have many characters'.length
  IRB
  message 'The thing after the dot is called a **method**. Methods are things you can do to a given **object**: more on Objects later, just recognize here that the Object is a String.'
  message "Here's some more methods for you to try:"
  irb <<-IRB
'forwards'.reverse
'jane smith'.upcase
'a plain old sentence'.delete('aeiou')
'some string'.methods
  IRB
  message "There's a method that's simply called `methods` -- it tells you all the methods you can use on a given object."
end

explanation do
  message "Strings are a key way to present information in your programs. Since a human will probably be reading the output of your program eventually, and humans speak words rather than numbers, you will often want to use strings."
  message 'A not at all complete summary of methods on String:'
  table class: 'bordered' do
    tr do
      td 'length'
      td 'how long is this string (characters)'
    end
    tr do
      td 'reverse'
      td 'return same string, reversed'
    end
    tr do
      td 'upcase'
      td 'return same string, IN UPPER CASE'
    end
    tr do
      td 'delete([another string])'
      td 'delete all characters in the second string from the first'
    end
    tr do
      td 'methods'
      td 'get the names of all methods you can perform on string'
    end
  end
end

further_reading do
  a "Ruby's documentation for String", href: 'http://www.ruby-doc.org/core-1.9.3/String.html'
end

next_step 'arrays'