ITP - more stuff - greet

Let's take a look a slightly more complex example. Note: try not to
worry about anything you don't understand in the code yet, just pay
attention to the stack trace and how it allows you to see what called
which method, and provides a trail of calls.

def space_out_letters(person)
  return person.split("").join(" ")
end

def greet(person)
  return "H e l l o, " + space_out_letters(person)
end

def decorate_greeting(person)
  puts "" + greet(person) + ""
end

decorate_greeting("John")
decorate_greeting(1)

Save this to greet.rb and run it, and you should see the following
output:

H e l l o, J o h n
greeting.rb:2:in space_out_letters': undefined methodsplit' for 1:Fixnum
(NoMethodError)
from greeting.rb:6:in greet' from greeting.rb:10:indecorate_greeting'
from greeting.rb:14:in `<main>'

The first example works as expected, the latter causes an exception.
Ordinarily this should pass the execution flow through as following:

main -> decorate_greeting -> greet -> space_out_letters (passes result
back) -> greet -> decorate_greeting -> main

Looking at the stack trace, you can see this happening: on line 14 (the
beginning of the chain where the error originated) the decorate_greeting
method is called. It then identifies line 10, where the greet method is
called by decorate_greeting, and then line 6 where greet calls
space_out_letters. Because the function 'split' expects a string, we get
an error, along with a trace of the calls that lead up to that error. In
a small script this is less useful, but in a larger codebase, being able
to trace the execution flow is a very useful way to drill down to the
source of the error.