HISE Logo Forum
    • Categories
    • Register
    • Login

    Get array by value

    Scheduled Pinned Locked Moved Scripting
    3 Posts 1 Posters 297 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.
    • d.healeyD
      d.healey
      last edited by d.healey

      Is there a way to pass an array by value instead of by reference?

      This example prints the value 50 to the console, but I want it to print 1.

      const var arr = [1, 2, 3, 4, 5]
      
      reg t = arr;
      
      t[0] = 50;
      
      Console.print(arr[0]);
      

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

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

        Well I found a solution but it makes me feel dirty :)

        inline function getByValue(a)
        {
            local s = a.join(",");
            return s.split(",");
        }
        

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

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

          I found a less dirty solution :)

          newArray = oldArray.clone();

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

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

          50

          Online

          1.7k

          Users

          11.7k

          Topics

          101.9k

          Posts