Skip to content

Instantly share code, notes, and snippets.

@michaelrkn
Created September 3, 2013 18:18
Show Gist options
  • Save michaelrkn/6427576 to your computer and use it in GitHub Desktop.
Save michaelrkn/6427576 to your computer and use it in GitHub Desktop.
a simple example of recursion
def say_smaller(word)
if word.length > 0
word + " " + say_smaller(word[0..-2])
else
""
end
end
puts say_smaller("piglet")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment