Forum

    • Register
    • Login
    • Search
    • Categories

    push to column in 2d array syntax?

    General Questions
    2
    3
    148
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LightandSound
      LightandSound last edited by

      array[index][index2] = array2[index][index2] works fine, any form of push (array[index].push etc just fails with cannot assign. Any clue on the correct syntax?

      1 Reply Last reply Reply Quote 0
      • d.healey
        d.healey last edited by d.healey

        Here's an example.

        const var my2darray = [[],[]];
        
        my2darray[0].push(58);
        my2darray[0].push(59);
        my2darray[0].push(60);
        
        my2darray[1].push("dog");
        my2darray[1].push("cat");
        my2darray[1].push("fish");
        
        Console.print(my2darray[1][1]);
        

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        LightandSound 1 Reply Last reply Reply Quote 1
        • LightandSound
          LightandSound @d.healey last edited by

          @d-healey so you have to array.push([]) first if you want to start pushing in to a new end column, that's where the issue was. Cheers!

          1 Reply Last reply Reply Quote 1
          • First post
            Last post

          10
          Online

          1.2k
          Users

          7.0k
          Topics

          64.7k
          Posts