Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Foo
- def m1
- puts "private"
- end
- def m2
- puts "protected"
- end
- private :m1
- protected :m2
- def m3 #Private and Proteceted can be invoked indirectly like this thorough a function
- m1
- m2
- end
- def m4 #Protected can be invoked thorough a reciever
- m2
- self.m2
- Foo.new.m2
- end
- def m5 # Private cannot have reciever so self.m1 and Foo.new.m1 will throw error
- m1
- end
- end
Add Comment
Please, Sign In to add comment