For my example: new_song is a Song object, which contains a sequence member variable. I have songs organized into playlists (also objects), and
next_song() is a member function of Playlist objects.
When running this code, I end up running
next_song() in this line, which is an issue as I intend to run this function only at the end of the sequence. I realize why this is happening, but I'm unsure of the remedy.
There must be something obvious that I'm just too tired to see, but I'm unsure of how to pass a member function as a callback to the
PS - I do see the obvious idea of making
next_song() a stand-alone function and passing the playlist. That might be where I go with it, but I'm still curious about the answer to this question. Member function as a callback solution would be preferred.
PPSS - I found another interesting solution. In
Playlist:init(self) I can declare the function as such:
self.next_song = function () print("do next song stuff") end
and then set the callback like this:
Is this inefficient? Maybe. Is this working? Yes.