Permalink
Browse files

OrderedMap now defines __pairs for Lua 5.2

  • Loading branch information...
1 parent 9deab58 commit ba40a1d5a9bf34edca2d21318c08a859f38bdbc8 @stevedonovan committed Jun 7, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 lua/pl/OrderedMap.lua
View
@@ -29,7 +29,7 @@ end
local assert_arg,raise = utils.assert_arg,utils.raise
---- update an OrderedMap using a table. <br>
+--- update an OrderedMap using a table.
-- If the table is itself an OrderedMap, then its entries will be appended. <br>
-- if it s a table of the form <code>{{key1=val1},{key2=val2},...}</code> these will be appended. <br>
-- Otherwise, it is assumed to be a map-like table, and order of extra entries is arbitrary.
@@ -130,6 +130,8 @@ function OrderedMap:iter ()
end
end
+OrderedMap.__pairs = OrderedMap.iter
+
function OrderedMap:__tostring ()
local res = {}
for i,v in ipairs(self._keys) do

0 comments on commit ba40a1d

Please sign in to comment.