How to add an element into a nested array in twig? I've decided to include opportunities of the bootstrap library in drupal native forum and I'm trying to add new class into a nested array in twig.
Here is my code.

{%  set topics['#rows'][0][0]['class'] = topics['#rows'][0][0]['class']|merge(['col-xs-9', 'col-sm-6']) %}
{%  set topics['#rows'][0][1]['class'] = topics['#rows'][0][1]['class']|merge(['col-xs-3', 'col-sm-2']) %}
{%  set topics['#rows'][0][2]['class'] = topics['#rows'][0][2]['class']|merge(['hidden-xs', 'col-sm-4']) %}
    

But upon executing the page an error is being displayed.
Here is description of the error.

Twig_Error_Syntax: Unexpected token "punctuation" of value "[" ("end of statement block" expected). в Twig_TokenStream-&gt;expect()


Could you clarify me, how to properly add new elements into the compound array ?
I managed to solve the problem via hook_preprocess.
Here's the code


function mytheme_preprocess_table__forum_topic_list(&$vars){
    $vars['header'][0]['attributes']->addClass(['col-xs-9', 'col-sm-6']);
    $vars['header'][1]['attributes']->addClass(['col-xs-3', 'col-sm-2']);
    $vars['header'][2]['attributes']->addClass(['hidden-xs', 'col-sm-4']);

    $vars['rows'][0]['cells'][0]['attributes']->addClass(['col-xs-9', 'col-sm-6']);
    $vars['rows'][0]['cells'][1]['attributes']->addClass(['col-xs-3', 'col-sm-2']);
    $vars['rows'][0]['cells'][2]['attributes']->addClass(['hidden-xs', 'col-sm-4']);
}