-
Notifications
You must be signed in to change notification settings - Fork 104
Import
Roland edited this page Sep 15, 2018
·
1 revision
All library functions can be imported in a context using import
into a specified context.
local context = {}
local M = require 'moses'
M.import(context)
context.each({1,2,3},print)
-- => 1 1
-- => 2 2
-- => 3 3
When no context
was provided, it defaults to the current environment, _ENV
or _G
.
M.import()
each({1,2,3},print)
-- => 1 1
-- => 2 2
-- => 3 3
Passing noConflict
argument leaves untouched conflicting keys while importing into the context.
local context = {each = 1}
M.import(context, true)
print(context.each) -- => 1
context.eachi({1,2,3},print)
-- => 1 1
-- => 2 2
-- => 3 3