Is there an equivalent method for table.HasValue(), but with keys?

Basically yeah. If I want to compare a key with data, is that possible? I looked through the table library and didn’t find anything that jumped out at me, but maybe I’m misunderstanding. I’d rather not do a “for” loop if possible ,just to save on cycles, as I’ll be running this logic fairly often.



function table_hasKey( tbl, key )
	for k,v in pairs(tbl) do
		if k==key then
			return true
		end
	end
	return false
end


it’s not that hard…

Arg. I was hoping I wouldn’t have to do that. guess that’s what I have to do though. I was hoping there was an existing way to do it, thanks for the help anyways.

It’s no different, than creating your own function. It may even run faster then the global function if you localize it. (don’t quote me on this I don’t know very much about lua’s speed)

what

[lua]if tbl[key] ~= nil then[/lua]

or am i missing something?

http://data2.whicdn.com/images/23158983/Patrick-+I+love+you_thumb.jpg