Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 62 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. class Foo
  2.   def m1
  3.     puts "private"
  4.   end
  5.  
  6.   def m2
  7.     puts "protected"
  8.   end
  9.  
  10.   private :m1
  11.   protected :m2
  12.  
  13.   def m3 #Private and Proteceted can be invoked indirectly like this thorough a function
  14.     m1
  15.     m2
  16.   end
  17.  
  18.   def m4        #Protected can be invoked thorough a reciever
  19.     m2
  20.     self.m2
  21.     Foo.new.m2
  22.   end
  23.  
  24.   def m5  # Private cannot have reciever so self.m1 and Foo.new.m1 will throw error
  25.     m1
  26.   end
  27. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top