On 10/5/18 1:12 AM, Todd Chester wrote:
Le ven. 5 oct. 2018 à 08:30, Todd Chester <toddandma...@zoho.com
<mailto:toddandma...@zoho.com>> a écrit :
Hi All,
I went to reply to someone, I think it was Brandon for sending me
an eMail to my private address and the stinker disappeared!
Anyway whoever sent me
$ p6 'say <the quick brown>[0,2];'
(the brown)
I was trying to figure out why this bombed:
$ p6 ' say "a b c d"[3,1];'
Index out of range. Is: 3, should be in 0..0
in block <unit> at -e line 1
And you beat me to the punch! It was the <>.
Thank you!
-T
On 10/5/18 12:31 AM, Laurent Rosenfeld via perl6-users wrote:
Yeah, Todd, the angle brackets operator in <the quick brown> produces
a list of three words which you can access individually with an index,
whereas quotes in "a b c d" creates a single string. But to come back
to the start of a very long thread of discussion over the last days,
if you want to access individual words of the string, you can of
course do this:
> say "a b c d".words[3,1];
(d b)
Cheers, Laurent.
Hi Laurent,
Thank you!
This makes it clear in my mind what is happening.
$ p6 'dd <a b c d>;'
("a", "b", "c", "d")
[] need to be given a "list" of things. And
$ p6 'dd "a b c d";'
"a b c d"
a string is not a list. The give away is the () that dd
produces.
-T
$ p6 ' say <"ab" "cd" "ef">[3,1];'
(Nil "cd")
:-)