Created
April 3, 2014 22:27
-
-
Save acook/9964142 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public | |
| protected | |
| NoMethodError: private method `pri_bar' called for #<Foo:0x007f8376ae2d28> | |
| from (pry):10:in `other_bar' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Foo | |
| public | |
| def pub_bar | |
| puts "public" | |
| end | |
| def other_bar other | |
| other.pub_bar | |
| other.pro_bar | |
| other.pri_bar | |
| end | |
| protected | |
| def pro_bar | |
| puts "protected" | |
| end | |
| private | |
| def pri_bar | |
| puts "private" | |
| end | |
| end | |
| f1 = Foo.new | |
| f2 = Foo.new | |
| f2.other_bar f1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment