danielpetisme

Untitled

Dec 6th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def text = 'hello world!'
  2.  
  3. String.metaClass.camelize = {
  4.   delegate.split().inject(""){ before, word ->
  5.     before += word[0].toUpperCase() + word[1..-1]
  6.   }
  7. }
  8. assert text.camelize() == "HelloWorld!"
Advertisement
Add Comment
Please, Sign In to add comment