Skip to main content

Anonymous function in BrightScript

Updated 1 min readMarkdown
Part of seriesBrightScript

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 )

No comments yet. Be the first to comment.