# this is ruby
(1,2,3).each { |i| puts i }
# this is perl 6
for 1,2,3 -> $i { say $i }
# being perl of course you can do this (which isn't that different to perl 5)
for 1,2,3 { say $_ }
# but now this (looks like things might be proper objects now...?)
for 1,2,3 { $_.say }
# and even this
for 1,2,3 { .say }
# Update: and finally (for the golfing win...)
.say for 1,2,3
So anyway, if that's interesting then have a look at http://perlcabal.org/syn/S04.html#The_for_statement
And some good stuff at http://perlcabal.org/syn/S12.html#Attributes also.
You can actually install rakudo now without much pain (at least it was pretty smooth on my ubuntu box), see http://www.rakudo.org/how-to-get-rakudo
No comments:
Post a Comment