Printing Functions

I want to know if it’s possible to retrieve data from what is given when printing a function (or before, tables).

Do the results returned even truly mean anything? Because when running something like this:

print(function() return 1 end)

It returns different result every time. Although it doesn’t when creating the function beforehand.

1 Like

in the function itself, did u used return

The result of the print is the memory address of the function. The only use case I can think of is debugging stuff that involves comparing functions.

This returns the memory adress of the function, because you never call it. When creating a function and calling it with a specific name you can return data. To get this to work, instead you can use an anonymous function.

print((function() return 1 end)())

So, it’s basically like a variable for the function, hence the different address whenever an anonymous function is called. Also, I just wanted to know that, not why the script wasn’t returning 1.