How do I iterate through an array inside a Raku hash? How do I iterate through an array inside a Raku hash? arrays arrays

How do I iterate through an array inside a Raku hash?


When you assign the value in the key arr to the Array @arr it takes the value in %json{'arr'} which is the Array Object ["alpha","beta","delta","gamma"] and puts it into @arr so you get an Array of Array's with 1 item.

You've got a few options :

You can bind @arr to %json{"arr"} with my @arr := %json{"arr"}

Or you can pass the %json{"arr"} to a list with my (@arr) = %json{"arr"}

You have to remember in Raku Array's are Objects.


As usual, after writing+posting my question, I answered my own question.

my @arr = %json{'arr'}.Array;

I don't quite understand why this is necessary, but it gives the desired behavior.