Difference between () and [] in Perl6 [migrated]
- by Ask and Learn
Learning Perl 6 and had trouble to understand following Perl 6 one liner.
version of Perl 6 - rakudo-star: stable 2014.04 (bottled)
This works fine, array/list is sorted
[njia@mb-125:~] : perl6 -e 'say [2443,5,33, 90, -9, 2, 764].sort'
-9 2 5 33 90 764 2443
But this does not sort the array/list, if [].sort works why @s.sort does not?
[njia@mb-125:~] : perl6 -e 'my @s = [2443,5,33, 90, -9, 2, 764]; @s.sort.say'
2443 5 33 90 -9 2 764
Change from [] to ()
[njia@mb-125:~] : perl6 -e 'my @s = (2443,5,33,90,-9,2,764); @s.sort.say'
-9 2 5 33 90 764 2443