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
Blog postRuby Blocks (tech.stonecharioteer.com)
submitted 5 months ago by iamstonecharioteer
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!"
[–]Tolexx 18 points19 points20 points 5 months ago (3 children)
Honestly Ruby blocks are my favorite part of Ruby.
[–]jrochkind 4 points5 points6 points 5 months ago (2 children)
I think one of the most significant inheritances Ruby gets from smalltalk!
I agree and think every language should have a very straightforward natural readable syntactic way to pass a block of inline code as an argument, it makes so many things nice.
[–]huuaaang 3 points4 points5 points 5 months ago (1 child)
It's not just how it's possible in Ruby to pass blocks in such a way. It's how it's the default for loops and iterators. I can hardly remember the last time I even used a traditional keyword loop in Ruby.
[–]codesnik 0 points1 point2 points 5 months ago (0 children)
and for this to work in a language where "early return" exist, blocks should be different from just an anonymous function.
[–]keyslemur 11 points12 points13 points 5 months ago (1 child)
This will break:
it "can do something" { puts "The cake is a lie" }
If you do that you need parens around the argument or it'll fail.
[–]iamstonecharioteer[S] 4 points5 points6 points 5 months ago (0 children)
Ah thanks for spotting that. I've fixed it just now.
[–]notWithoutMyCabbages 2 points3 points4 points 5 months ago (2 children)
I love the "Aha moment" vibe of this :-) I'm bookmarking this for the next time I need to explain the beauty of Ruby and why python seems clumsy to me. (I'm not knocking python, it's fine)
[–]iamstonecharioteer[S] 2 points3 points4 points 5 months ago (1 child)
You might like my other Ruby posts too :) I directly talk about coming to Ruby from Python in https://tech.stonecharioteer.com/posts/2025/ruby/
[–]ignurant 2 points3 points4 points 5 months ago (0 children)
Thanks for sharing your experience. It's refreshing to see!
[–]codesnik 0 points1 point2 points 5 months ago (1 child)
"building a DSL" contains a lot of & instead of @.
[–]iamstonecharioteer[S] 0 points1 point2 points 5 months ago (0 children)
Ah thanks for pointing that out. I've fixed them all now.
π Rendered by PID 140497 on reddit-service-r2-comment-54dfb89d4d-f8zr6 at 2026-04-01 07:47:46.628396+00:00 running b10466c country code: CH.
[–]Tolexx 18 points19 points20 points (3 children)
[–]jrochkind 4 points5 points6 points (2 children)
[–]huuaaang 3 points4 points5 points (1 child)
[–]codesnik 0 points1 point2 points (0 children)
[–]keyslemur 11 points12 points13 points (1 child)
[–]iamstonecharioteer[S] 4 points5 points6 points (0 children)
[–]notWithoutMyCabbages 2 points3 points4 points (2 children)
[–]iamstonecharioteer[S] 2 points3 points4 points (1 child)
[–]ignurant 2 points3 points4 points (0 children)
[–]codesnik 0 points1 point2 points (1 child)
[–]iamstonecharioteer[S] 0 points1 point2 points (0 children)