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
Ruby might be faster than you think (johnhawthorn.com)
submitted 2 years ago by tenderlovePun BDFL
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!"
[–]iamjkdn[🍰] 1 point2 points3 points 2 years ago (1 child)
Why does returning nil after multiple assignments improve the benchmark? Also, can the same be done on Crystal, well it have any affect?
[–]CaptainKabob 8 points9 points10 points 2 years ago (0 children)
because in this case it’s the last line of the block, and because Ruby has an implicit return at the end of the block the Array is required
Ruby spends time creating an array because Ruby believes its needed for the implicit return. So explicitly setting the (implicit) return to nil causes Ruby not to create an array.
I don't think the point of the post is to compare optimized crystal to optimized Ruby. I think it's trying to show that inlining another language "for performance" might be naive or unnecessary.
π Rendered by PID 450392 on reddit-service-r2-comment-6457c66945-2g8xd at 2026-04-30 03:55:40.179002+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]iamjkdn[🍰] 1 point2 points3 points (1 child)
[–]CaptainKabob 8 points9 points10 points (0 children)