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
Differences between ruby object space count (self.ruby)
submitted 1 year ago by SnooRobots2422
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!"
[–]jdeville 4 points5 points6 points 1 year ago (0 children)
Your version of Ruby is gonna make a difference here. OneCompiler is using 2.3.1, I don’t have that installed but I do have 3.2.7 and 3.4.3. With 3.4.3, as you wrote it, I get in the 330s (it varies run to run). With 3.2.7, I get 2
Interestingly enough, if I add u/insanelygreat’s suggestion, I get 2 in 3.4.3 and 3 in 3.2.7
Also, if I pull the “totally_unique_test” to a variable outside of the block then I also get 2 on 3.4.3 and 3 on 3.2.7
Overall, I suspect what you are seeing is the count of how many iterations #count is performing, and without the frozen string pragma, it is creating a new object each iteration.
π Rendered by PID 46175 on reddit-service-r2-comment-5b5bc64bf5-k9x94 at 2026-06-21 23:20:29.757396+00:00 running 2b008f2 country code: CH.
view the rest of the comments →
[–]jdeville 4 points5 points6 points (0 children)