<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Atable%2FsetNested</id>
	<title>Module:table/setNested - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Atable%2FsetNested"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:table/setNested&amp;action=history"/>
	<updated>2026-05-22T22:49:06Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:table/setNested&amp;diff=495427&amp;oldid=prev</id>
		<title>Sware: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:table/setNested&amp;diff=495427&amp;oldid=prev"/>
		<updated>2026-04-21T12:01:17Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:01, 21 April 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:table/setNested&amp;diff=475299&amp;oldid=prev</id>
		<title>Sware: Created page with &quot;local error = error local select = select  --[==[ Given a table, value and an arbitrary number of keys, will successively access subtables using each key in turn, and sets the value at the final key. For example, if {t} is { {} }, {export.setNested(t, &quot;foo&quot;, 1, 2, 3)} will modify {t} to { {[1] = {[2] = {[3] = &quot;foo&quot;} } } }.  If no subtable exists for a given key value, one will be created, but the function will throw an error if a non-table value is found at an intermedia...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:table/setNested&amp;diff=475299&amp;oldid=prev"/>
		<updated>2025-11-04T21:38:22Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local error = error local select = select  --[==[ Given a table, value and an arbitrary number of keys, will successively access subtables using each key in turn, and sets the value at the final key. For example, if {t} is { {} }, {export.setNested(t, &amp;quot;foo&amp;quot;, 1, 2, 3)} will modify {t} to { {[1] = {[2] = {[3] = &amp;quot;foo&amp;quot;} } } }.  If no subtable exists for a given key value, one will be created, but the function will throw an error if a non-table value is found at an intermedia...&amp;quot;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 21:38, 4 November 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:table/setNested&amp;diff=495426&amp;oldid=prev</id>
		<title>wikt&gt;Theknightwho at 21:34, 14 May 2025</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:table/setNested&amp;diff=495426&amp;oldid=prev"/>
		<updated>2025-05-14T21:34:31Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local error = error&lt;br /&gt;
local select = select&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Given a table, value and an arbitrary number of keys, will successively access subtables using each key in turn, and sets the value at the final key. For example, if {t} is { {} }, {export.setNested(t, &amp;quot;foo&amp;quot;, 1, 2, 3)} will modify {t} to { {[1] = {[2] = {[3] = &amp;quot;foo&amp;quot;} } } }.&lt;br /&gt;
&lt;br /&gt;
If no subtable exists for a given key value, one will be created, but the function will throw an error if a non-table value is found at an intermediary key.&lt;br /&gt;
&lt;br /&gt;
Note: the parameter order (table, value, keys) differs from functions like rawset, because the number of keys can be arbitrary. This is to avoid situations where an additional argument must be appended to arbitrary lists of variables, which can be awkward and error-prone: for example, when handling variable arguments ({...}) or function return values.]==]&lt;br /&gt;
return function(...)&lt;br /&gt;
	local n = select(&amp;quot;#&amp;quot;, ...)&lt;br /&gt;
	if n &amp;lt; 3 then&lt;br /&gt;
		error(&amp;quot;Must provide a table, value and at least one key.&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	local t, v, k = ...&lt;br /&gt;
	for i = 4, n do&lt;br /&gt;
		local next_t = t[k]&lt;br /&gt;
		if next_t == nil then&lt;br /&gt;
			-- If there&amp;#039;s no next table while setting nil, there&amp;#039;s nothing more&lt;br /&gt;
			-- to do.&lt;br /&gt;
			if v == nil then&lt;br /&gt;
				return&lt;br /&gt;
			end&lt;br /&gt;
			next_t = {}&lt;br /&gt;
			t[k] = next_t&lt;br /&gt;
		end&lt;br /&gt;
		t, k = next_t, select(i, ...)&lt;br /&gt;
	end&lt;br /&gt;
	t[k] = v&lt;br /&gt;
end&lt;/div&gt;</summary>
		<author><name>wikt&gt;Theknightwho</name></author>
	</entry>
</feed>