That’s where blocks come in, to simplify the definition and use of these buttons making maintenance simpler so we could call the specific block to which we pass on the necessary parameters or methods to attain the final outcome. Below is an example of how this can be achieved with blocks creating a class called [...]
Tag Archives: closure
Blocks as Closures (Part 2)
Sample Code: class PlayButton < Button def initialize super(“Play”) # invoke Button’s initialize process end def buttonSelected # do something that should be done when the start button is pressed end end bPlay = PlayButton.new This type of approach would bring about two very problematic scenarios; one, the actions that are to be done when [...]