Special characters as elements of a string array in Perl 6

If I understand correctly, when I assign values ​​to arraystrings with < ... >, I should avoid special characters with \:

> my @array = < \\ a b>
[\ a b]
> my @array = < \< a b>
[< a b]
> my @array = < \<de\< a b>
[<de< a b]

Using a backslash is not always convenient, sometimes the code may become unclear.

Is there a better way to pass a list of strings containing special characters to an array?

+6
source share
1 answer

Use << >>instead < >and use single quotes inside:

> my @array = << '<de<' a b>>
[<de< a b]
+7
source

All Articles