Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created February 26, 2012 20:59
Show Gist options
  • Save havenwood/1918966 to your computer and use it in GitHub Desktop.
Save havenwood/1918966 to your computer and use it in GitHub Desktop.
Comparing sentence capitalization in Perl6 and Ruby
perl6:
my $sentence = "an acorn fell here."
#=> an acorn fell here.
my @words = $sentence.split(" ")
#=> an acorn fell here.
say @words.capitalize
An Acorn Fell Here.
ruby:
sentence = "acorns do not exist."
#=> "acorns do not exist."
words = sentence.split
#=> ["acorns", "do", "not", "exist."]
words.each { |word| print word.capitalize }
Acorns Do Not Exist.
@briandfoy
Copy link

I know you did this a long time ago, but now Perl 6 can do:

"an acorn fell here.".wordcase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment