The joy of dynamic dispatching
I like to write as little code as possible. One way to do that is to use method names (symbols), and use send() to dispatch on those values:
class EventNothing big, but using it often can eliminate a lot of if statements.
def initialize( type, args )
@type, @args = type, args
end
end
def send_event( event )
send( event.type, *event.args )
end
def mouse_down( origin )
puts 'mouse_down()'
end
view.send_event( MouseEvent.new( :mouse_down, [50, 50] ) )
1 Comments:
wow power leveling
wow powerleveling
wow power leveling
wow gold
wow items
feelingame.com
wow tips
Most Valuable WOW Power Leveling Service
wow power leveling faq
cheap wow power leveling
wow power leveling
wow powerleveling
wow power lvl
By Anonymous, at 10:40 PM
Post a Comment
<< Home