I use sum() all the time, but inject() theoretically allows computation to happen without loading EVERYTHING into memory actually trying to TRAIN myself to use inject more bc it's the RIGHT THING, even as I prefer sum
-
-
The rails sum method seems to be on enumerable and is documented to behave identially to inject so I'd expect that if what you have under the hood is a resultset like thing it *should* do the right thing? (though I'd likely RTFS to double check "does" versus "should" ;)
-
Honestly in perl code I'd probably do the moral equivalent of .pluck("SUM(amount)")[0] (pseudo-ruby, no warrantry express or implied)
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.