Created
June 18, 2012 21:31
-
-
Save perspectivezoom/2950850 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Mark_twain | |
def mark_twain | |
mark_twain_helper(self, []) | |
end | |
def mark_twain_helper(str, accum_ar) | |
if str.split.length == 1 | |
accum_ar << "Final draft: #{str}." | |
accum_ar | |
else | |
accum_ar << "Draft: #{str}." | |
reduced_str = str.split[(0..-2)].join(" ") | |
mark_twain_helper( reduced_str , accum_ar ) | |
end | |
end | |
end | |
class String | |
include Mark_twain | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment