Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Are you ready for Perl6? (github.com/cygx)
3 points by cygx on Nov 2, 2015 | hide | past | favorite | 2 comments


How about an explanation of what is going on here?


It's a combination of the | prefix operator that interpolates into a list, the ~ prefix stringification operator and the => infix pair constructor via << hyper operators so it works with a single value on the left and an array on the right.

So if $bin contained a list like [42, "foo", 7], we would get out a list of pairs

    1 => "42", 1 => "foo", 1 => "7"
Another way to write it would have been something along the lines of

    ($bin // Empty).map({ 1 => .Str }).slip
I did _not_ set out to write the code as obscurely as possible - it just happened 'naturally' ;)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: