functions as variable values

Create issue
Issue #26 invalid
mezzodrinker created an issue

I was thinking about creating some tables with functions as their data values for my script (for e.g. random menus). It could eventually look a bit like this:

// Value assignment
$var = function(arg1, arg2)
  // Do something in here
end;

// Function call
$var();

Would be awesome if something like this could be implemented.

Comments (4)

  1. Fabian Maurer

    But you can aready store functions in tables/variables. I have implemented random menus in my script.

  2. Fabian Maurer

    For example like this:

    function testFunc($var1, $var2)
        say $var1 $var2;
    end
    
    label Start
        $tableTest = {};
        $tableTest[0] = $testFunc;
        $tableTest[0]("Creeper", "Hello!");
    end
    
  3. Log in to comment