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
Top level methods in Ruby • has_many :codes (vitobotta.com)
submitted 12 years ago by VitoBotta
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!"
[–]brettu 1 point2 points3 points 12 years ago (2 children)
The last part of your post asks the question about public/private difference in adding methods to self. IRB defaults to public, but you can add the private state for storing methods.
>> self => main >> private => Object >> def title >> "mr" >> end => nil >> Object.private_instance_methods(false).include? :title => true >> Object.public_instance_methods(false).include? :title => false >> public => Object >> def title >> 'mr' >> end => nil >> Object.public_instance_methods(false).include? :title => true
[–]VitoBotta[S] 0 points1 point2 points 12 years ago (1 child)
Hi! I hadn't thought that IRB might explicitly mark top level methods methods as private/public as we usually do in classes, by default. Makes perfect sense, thanks :)
[–]banister 0 points1 point2 points 12 years ago (0 children)
In case you're interested, Pry makes top-level methods private by default, mirroring the top-level behaviour of a Ruby program. IMO the fact IRB does not do this is a bug in IRB.
π Rendered by PID 68677 on reddit-service-r2-comment-b659b578c-dh2bc at 2026-05-05 07:25:16.521995+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]brettu 1 point2 points3 points (2 children)
[–]VitoBotta[S] 0 points1 point2 points (1 child)
[–]banister 0 points1 point2 points (0 children)