From 4a851699d960460047fad6af4f0f25cd181c6048 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Sun, 19 Mar 2017 19:16:20 -0400 Subject: [PATCH] This would work better, actually...! --- examples/optional_with_iteration.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/optional_with_iteration.cpp b/examples/optional_with_iteration.cpp index a7c8e439..b4e571c8 100644 --- a/examples/optional_with_iteration.cpp +++ b/examples/optional_with_iteration.cpp @@ -49,7 +49,7 @@ int main(int, char**) { // Our recursive function // We use some lambda techniques and pass the function itself itself so we can recurse, // but a regular function would work too! - auto fx = [&lua, &things](auto& f, auto tbl) -> void { + auto fx = [&lua, &things](auto& f, auto& tbl) -> void { // You can iterate through a table: it has // begin() and end() // like standard containers @@ -63,9 +63,11 @@ int main(int, char**) { const sol::object& value = key_value_pair.second; sol::type t = value.get_type(); switch (t) { - case sol::type::table: - f(f, value.as()); - break; + case sol::type::table: { + sol::table inner = value.as(); + f(f, inner); + } + break; case sol::type::userdata: { // This allows us to check if a userdata is // a specific class type