Created
February 26, 2012 20:59
-
-
Save havenwood/1918966 to your computer and use it in GitHub Desktop.
Comparing sentence capitalization in Perl6 and Ruby
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
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I know you did this a long time ago, but now Perl 6 can do:
"an acorn fell here.".wordcase