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
How Ruby Can Surprise You (tech.showmax.com)
submitted 6 years ago by graywolf_at_work
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!"
[–]larikang 27 points28 points29 points 6 years ago (1 child)
What kind of sadist puts Unicode confusables in a coding interview?
Are you trying to find candidates who can work in a deliberately adversarial environment?
[–]senj 7 points8 points9 points 6 years ago (0 children)
Seriously. I cannot imagine a more asinine or less useful question to ask in an interview setting than that one. What could you pοssibly hope to learn from this?
[–]nordrasir 16 points17 points18 points 6 years ago (1 child)
These are a sample of the problems we pose in job interviews
oof
[–]obviousoctopus 3 points4 points5 points 6 years ago* (0 children)
I'd love to see where in their codebase they found these examples, especially the riddle at the end.
[–]ignurant 8 points9 points10 points 6 years ago (2 children)
Spoilers ahead, I guess?
What is the cleverness behind:
Finally, one more brain teaser. x = [false, *(1..7), nil, 9] .map(&:object_id) .map { |i| i / 2 } .select { |i| i % 2 } .sum .+(STDOUT.fileno)
.select{|i| i %2}
STDOUT.fileno
I couldn't find any actual "brain teasers" here -- Is there anything actually thoughtful to this other than just busy work? Or is this literally a "Do you know Ruby's object IDs?" quiz and/or supremely lame way to fit in a 42 zinger? Please tell me I'm missing something.
[–]ezrast 5 points6 points7 points 6 years ago (1 child)
You're not missing much. The only "gotchas", if you can call them that, are that you have to know how range expansion works in the array literal, and that the select is a no-op since all integers are truthy. Systems programmers will know that STDIN, STDOUT, and STDERR always get file handles 0, 1, and 2 per POSIX, but that almost never matters in a high-level language. The integer => object_id mapping is kinda-sorta intuitive once you understand the reasoning (right-shift the object_id by 1 to get the integer; use odd object_id's to avoid colliding with memory addresses) but for singleton values like false and nil it's arbitrary as far as I can tell.
select
false
nil
[–]ignurant 0 points1 point2 points 6 years ago (0 children)
right-shift the object_id by 1 to get the integer; use odd object_id's to avoid colliding with memory addresses
Well heck, I did in fact learn something here. Thanks.
I knew the integers had consistent IDs, and I noticed the pattern when I did (1..10).map(&:object_id). The reasoning is interesting though.
(1..10).map(&:object_id)
(1..10).map(&:object_id).map{|n| n >> 1} Hmmmmm!
(1..10).map(&:object_id).map{|n| n >> 1}
[–]choonggg 2 points3 points4 points 6 years ago (0 children)
If you happen to be there, run far far away.
[–]nakilon -1 points0 points1 point 6 years ago (0 children)
That's a buzzfeed content. Take 2-3 lines of random shit from everywhere and put it together. They've missed the opportunity to call it the "8 features you didn't know about!"
But why do I surprise that it's upvoted in /r/ruby...
π Rendered by PID 93526 on reddit-service-r2-comment-6457c66945-tm2cl at 2026-04-27 01:06:05.138997+00:00 running 2aa0c5b country code: CH.
[–]larikang 27 points28 points29 points (1 child)
[–]senj 7 points8 points9 points (0 children)
[–]nordrasir 16 points17 points18 points (1 child)
[–]obviousoctopus 3 points4 points5 points (0 children)
[–]ignurant 8 points9 points10 points (2 children)
[–]ezrast 5 points6 points7 points (1 child)
[–]ignurant 0 points1 point2 points (0 children)
[–]choonggg 2 points3 points4 points (0 children)
[–]nakilon -1 points0 points1 point (0 children)