Skip to main content

Command Palette

Search for a command to run...

Anonymous function in BrightScript

Updated
1 min read

Not the prettiest code but if you must use anonymous function as a function argument in BrightScript you can. This would be the equivalent to JavaScript Arrow Function.

' This function applies a passed function to an argument  '
apply = function ( a, fn ) 
    fn(a)
end function

' Here we apply a string to an anonymouse function which prints its argument a '
apply( "foo", function(a) 
                print a
              end function )