Blocks as Closures (Part 1)

As it turns out, blocks are the ideal tool for use ion implementing user interfaces where we have a defined graphic that signifies a button and pressing that button would result in a pre-set series of processes. A simple button definition can be:

bPlay = Button.new(“Play”)
bPause = Button.new(“Pause”)
# so on and so forth……

If a user presses any of the buttons it calls on the pre-set reactions/processes that are supposed to happen if the user requests that action, say a method called “buttonSelected” will be called upon. The said method would then have to have it’s own method as a sub-class of the button action sub-class. This can be done by defining the sub-class such as the sample code in the next post would show.

This entry was posted in Development, Programming Basics and tagged , . Bookmark the permalink. Comments are closed, but you can leave a trackback: Trackback URL.