- Edited
Hi All!
Is there a way to declare funcs within funcs? Mostly for organizing code in a tree like structure and codefolding. eg.:
func initall():
func loadallpngs():
func loadapng(id:int):
var s=TextureRect.new()
s.texture=load(resnames[i])
loadedpngs.append(s)
for i in range(10):
loadapng(i)
func initmap():
...
func initvars():
...
loadallpngs()
initmap()
initvars()
//end of initall()
etc.
I always get: Error parsing expression, misplaced: func
? Thanks for all your answers.
Edit: Thanks for the tip with Edit
Basically, I would like to create functions in the local scope of another function. In the example above I would just call initall() from somewhere in the program and it would do all the things inside of it (loadallpngs, initmap, initvars) by itself. I could then fold initall(), making my program look neat and easy to browse, like a tree of functions.
C# calls them local functions https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/local-functions
here is a c++ example https://notesformsc.org/c-local-functions/
Edit: local function in title name now