From: Sean O'Dell Date: 2002-03-28T07:10:09+09:00 Subject: Proc/Method objects are great Just thought I would share something I just did with Ruby that I thought was really something. Probably a bit boring for some of you. I have a group of Ruby scripts that get called by a main script, and instead of just running them like stand-alone scripts, I wanted to somehow "load" them and then call a known method (known by name) in each script at certain points in the main script. The scripts themselves are part of a modular system, and the main script really doesn't know too much about what they do, so it was important that I be able to add/remove scripts from this system without having to fiddle around with the main script that calls them. The way I ended up handling this was using "require" to load the scripts once, if needed, then using .method("") to obtain a module method which is provided by each script, storing the method object in an array, which I then call several times later. This allowed the main script to set up a more complex environment that the individual scripts have direct access to, as well as providing a library of functions the scripts themselves can rely on, making them very tidy and containing only a minimal amount of code to just perform their tasks. Allowing the use of "require" in regular code was a good idea, but being able to call a method through its associated object which was obtained using a call to .method("") which provided the object using its string name as a lookup...that was just a great idea, Matz. This is a truly amazing language sometimes. I have yet to experience a situation where I can't solve a problem the way I think is the most natural way to solve it using Ruby...it's just being very good to me. Sean