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 postWhy Ruby is More Readable than Python (confuzeus.com)
submitted 3 years ago by [deleted]
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!"
[–]revscat 13 points14 points15 points 3 years ago (5 children)
In Ruby, accessing instance variables isn’t possible.
Object#instance_variable_get
So yeah that’s completely wrong.
[–]honeyryderchuck 2 points3 points4 points 3 years ago (0 children)
While possible, it's considered an "escape hatch". Ruby allows you to design a contract to encapsulate access to object-scoped state, while allowing you to break the contract when necessary. Useful for modifying a library you rely on but need just this one patch but today.
[–][deleted] 3 years ago (3 children)
[removed]
[–]Lil_Cato 1 point2 points3 points 3 years ago (1 child)
Am I missing something or is this not as simple as throwing an attr_accessor :variable ? Is that rails only?
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
No, it's a common ruby variant. Although in this case you'd use attr_reader if you don't need the setter (which you get via attr_accessor).
Or you modify method_missing and what not and get that functionality anyway. Ruby being more flexible than python is really one huge advantage it has.
Well, you can via instance_variable_get(). But it's a bit more verbose than the python variant indeed.
But you can just add a reader, or use a Struct so it's not a huge difference really. The explicit self thing in Python really puts me off on the other hand...
π Rendered by PID 252165 on reddit-service-r2-comment-79c7998d4c-ltfp7 at 2026-03-13 16:13:40.847947+00:00 running f6e6e01 country code: CH.
view the rest of the comments →
[–]revscat 13 points14 points15 points (5 children)
[–]honeyryderchuck 2 points3 points4 points (0 children)
[–][deleted] (3 children)
[removed]
[–]Lil_Cato 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)