Skip to content

Instantly share code, notes, and snippets.

@jdsumsion
Created October 30, 2011 03:54
Show Gist options
  • Save jdsumsion/1325447 to your computer and use it in GitHub Desktop.
Save jdsumsion/1325447 to your computer and use it in GitHub Desktop.
Backward Names
def backwards_name(name)
name.split(/ +/)
.map { |piece| piece = piece.reverse; "#{piece[0].upcase}#{piece[1..-1].downcase}" }
.join(" ")
end
>> backwards_name "John Sumsion"
=> "Nhoj Noismus"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment