Permalink
Browse files

indexOf can take a function

  • Loading branch information...
1 parent 6e6652c commit e9acb4026a7ccb1b8a8369001209b8cdd878e543 @probablycorey committed May 31, 2011
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/stdlib/ext/table.lua
View
@@ -61,7 +61,11 @@ end
function table.indexOf(t, value)
for k, v in pairs(t) do
- if v == value then return k end
+ if type(value) == "function" then
+ if value(v) then return k end
+ else
+ if v == value then return k end
+ end
end
return nil

0 comments on commit e9acb40

Please sign in to comment.