Exercise

Closures keep your values safe

You are still helping your niece understand closures. You have written the function get_new_func() that returns a nested function. The nested function call_func() calls whatever function was passed to get_new_func(). You've also written my_special_function() which simply prints a message that states that you are executing my_special_function().

You want to show your niece that no matter what you do to my_special_function() after passing it to get_new_func(), the new function still mimics the behavior of the original my_special_function() because it is in the new function's closure.

Instructions 1/3

undefined XP
  • 1

    Show that you still get the original message even if you redefine my_special_function() to only print "hello".

  • 2

    Show that even if you delete my_special_function(), you can still call new_func() without any problems.

  • 3

    Show that you still get the original message even if you overwrite my_special_function() with the new function.