From: James Britt Date: 2007-07-22T15:45:42+09:00 Subject: Re: Method to return elements of an array in numeric 'rank'? Jenny Purcell wrote: > On Sun, 22 Jul 2007 11:44:40 +0900, James Britt > wrote: > >> Jenny Purcell wrote: >> >>> I would expect there would be an existing method that works off of the >>> array class that would do this, and I'd like to check on that before >>> (painfully) writing my own nested loops that would do the same thing. >> See http://www.ruby-doc.org/core/classes/Enumerable.html#M003151 >> >> Look at sort_by >> >> >> Also, in your code, consider representing objects of interest (such as >> horses and races) by defining suitable classes. >> >> I think you code would be easier to follow if, for example, it managed a >> collection of Horse objects. > > I realize it would be easier for people in the fgroup to follow if I > was programming with objects. However, I just don't understand OO > programming, my skills (such as they are) are procedural. Skill to do comes of doing. And you can ask for help on ruby-talk. > > Ruby was pointed out to me as a language that would allow me to write > procedural programs and so far it is working out very nicely in that > regard. That will not carry very far. While it is technically true that one can use Ruby to write procedural code that does not make it a good idea. It's a fair bet that at some point maintainability will approach zero unless you employ some higher abstractions Classes and objects are one approach to this. When you have procedural code that works (and you *are* using Ruby's unit testing libraries, right? :)) consider refactoring it into something more OO. It might make life simpler all around. Just a suggestion. -- James Britt "In physics the truth is rarely perfectly clear, and that is certainly universally the case in human affairs. Hence, what is not surrounded by uncertainty cannot be the truth." - R. Feynman