HISE Logo Forum
    • Categories
    • Register
    • Login

    push to column in 2d array syntax?

    Scheduled Pinned Locked Moved General Questions
    3 Posts 2 Posters 354 Views
    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.
    • LightandSoundL
      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.healeyD
        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

        LightandSoundL 1 Reply Last reply Reply Quote 1
        • LightandSoundL
          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

          56

          Online

          1.7k

          Users

          11.7k

          Topics

          101.9k

          Posts