Topic: Quick Tip: One for all and all for One!
I just converted a method that used to take (among other arguments) one id in aparamter and do a bunch of stuff lookups and computations and (gasp) return some result.
Next thing I know is that I really need another method just like that one, that does it's thing for an entire list of id's. Here is one thing I did to simplify my code and use just a single method than can handle either a single id, or an array of ids:
def big_method(id_or_ids, other, args, here)
ids = [id_or_ids].flatten
I know you it's kind of a yawner, but it beats doing things like this:
ids = id_or_ids
ids = [ id ]
Anyhow -- once you got "ids", you know it's an array, and you can convert the entire method to just work on the array. Ok ok ... I'm just still excited by ruby is all.