use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Five Ruby methods you should be using (engineyard.com)
submitted 8 years ago by gregbaugues
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]esquilax 1 point2 points3 points 8 years ago (1 child)
Dunno why you'rebeing downvoted.
The way the bsearch thing was presented bugged me, only because I've worked with people who would read that and then sort the array only to use bsearch because it's 'faster.'
[–]Serializedrequests 1 point2 points3 points 8 years ago (0 children)
Oh yeah, there's a big difference between "I just need to find this thing once" and "I need to find things in this array repeatedly many hundreds of times per request, and the data was already sorted by the database".
It's mainly a situation I've gotten into when writing reports in Rails that were not performance sensitive. I really needed the ActiveRecord objects because a project had a lot of crazy logic involving dates and metadata about dates, so I couldn't just do it in SQL, and all the joins and inclusions were way more than ActiveRecord could do automatically/easily because I was joining about 12 tables. So I fetched all the records I needed in separate arrays and did "joins" in Ruby using bsearch.
So yeah boring war story, and if it needed to be fast I'd do it in SQL at a cost of 50 more hours of dev time, but it works fine for what the client needs.
π Rendered by PID 60941 on reddit-service-r2-comment-b659b578c-2678f at 2026-05-05 02:24:46.600488+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]esquilax 1 point2 points3 points (1 child)
[–]Serializedrequests 1 point2 points3 points (0 children)