Skip to content

Instantly share code, notes, and snippets.

@JimOfLeisure
Last active January 13, 2022 07:16
Show Gist options
  • Save JimOfLeisure/824bb7ebf04745ac36a13fd994def07a to your computer and use it in GitHub Desktop.
Save JimOfLeisure/824bb7ebf04745ac36a13fd994def07a to your computer and use it in GitHub Desktop.
Just a quick demo of a callback in Lua, inspired by a Discord discussion
local function just_print_it(text)
print(text)
end
local function print_it_backwards(text)
print(string.reverse(text))
end
local function do_something(text, callback)
-- do neat stuff
callback(text)
end
do_something("hello", just_print_it)
do_something("goodbye", print_it_backwards)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment