Jigar Patel Driving fast in a slow lane!

Private or Protected? Use Private!!!

July 29, 2010 / Jigar Patel

Ruby has a closely related keyword called protected that differs subtly from private. As far as I can tell, the only reason to learn the difference is so that you can ace a job interview that asks you “In Ruby, what is the difference between private and protected?” But do you really want to work at a company that asks you such a lame interview question? At his keynote at RubyConf in 2008, Dave Thomas (author of Programming Ruby) suggested eliminating protected from future versions of Ruby, and I agree with the sentiment. Just use private and you’ll be fine.

Michael Hartl (RailsTutorial.org)