summaryrefslogtreecommitdiff
path: root/Data/Libraries/Penlight/examples/test-listcallbacks.lua
blob: a9a31c32cd6ac1a9bfd90714f9c3b4e24fa1e4bc (plain)
1
2
3
4
5
6
7
8
9
10
11
-- demonstrates how to use a list of callbacks
local List = require 'pl.List'
local utils = require 'pl.utils'
local actions = List()
local L = utils.string_lambda

actions:append(function() print 'hello' end)
actions:append(L '|| print "yay"')

-- '()' is a shortcut for operator.call or function(x) return x() end
actions:foreach '()'