View Single Post
04-01-22, 12:36 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
Let's take your earlier code for example.

Option 1:
(Depth check was moved to before attempting to recursive call)
Code:
	for k, v in pairs(tbl) do
		if type(v) ~= 'table' then
			print(v)
		elseif depth > 1 then
			scope(v, depth - 1)
		else
			print("Maximum depth reached!")
		end
	end
Option 2:
Code:
	if depth > 0 then
		for k, v in pairs(tbl) do
			if type(v) ~= 'table' then
				print(v)
			else
				scope(v, depth - 1)
			end
		end
	else
		print("Maximum depth reached!")
	end
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote