Module:Util/tables/_property

From Zelda Wiki, the Zelda encyclopedia
Jump to navigation Jump to search

A curried version of Module:Util/tables/property.

_property(key)

Returns

  • A function that accepts a table and returns the table's value for key

Examples

#InputOutputStatus
1
local getAbbr = util.tables._property("abbr")
return getAbbr({ abbr = "OoT", title = "Ocarina of Time" })
"OoT"
2
local getAbbr = util.tables._property("abbr")
return getAbbr({ title = "Bayonetta" })
nil

local function _property(key)
	return function(tbl)
		return tbl[key]
	end
end

return _property