Skip to content

Commit 5f5a4a6

Browse files
authored
Improve $^foo var naming example
1 parent e978918 commit 5f5a4a6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

doc/Language/traps.pod6

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,13 @@ The trouble arises when a person wants to use more complex names for the variabl
776776
777777
Due to the variables allowed to be called anything, this can cause some problems if you are not accustomed to how Perl 6 handles these variables.
778778
779-
=for code
779+
=begin code
780+
# BAD NAMING: alphabetically `four` comes first and gets value `1` in it:
780781
for 1..4 { say "$^one $^two $^three $^four"; } # OUTPUT: «2 4 3 1␤»
782+
783+
# GOOD NAMING: variables' naming makes it clear how they sort alphabetically:
784+
for 1..4 { say "$^a $^b $^c $^d"; } # OUTPUT: «1 2 3 4␤»
785+
=end code
781786
782787
=head1 Scope
783788

0 commit comments

Comments
 (0)