What is ruby partial class? -
I've read that the code snippet below applies to partial class :
class A DF puts one 'A' and end class B & lt; A.D.F. BAI 'BA1' & End Class ADBB 'B' & End Class B & LT; A.D.F. BA 2 'BA 2' & End OB = B.N.O.A.A. Ob.b ob.ba1 puts OBB2
two squares are b
from the expanded two classes a
. I can not understand how Ruby can know which A
to b
is expanded when making an example of b
So how does Rabbi know which code is ? The execution result is:
ab ba1 ba2
is an example of the initial B
two B
Code> Classes Can anyone explain this?
When you type a class in ruby already declared , You do not override the square, rather patch .
This means that the old definition of Ruby is not forgotten, but rather
there is only one : In this example, Although they can not do this, for example - change the original class of a class. If we try to get the above code, and declare another block: You get an error saying that you are trying to change the base class , Which is impossible (if there is no legacy declaration in the initial declaration, class is included with the B class - this is both
class B < There is mixed code in the / code> block. Example for
Sets class AF one 'A' and end A = A Au a. Public_maths (false) # = & gt; [: A] Category ADFB 'B' and End A. Public_mothis (fotos) # = & gt; [: A, b]
A
is written a
But, as you can see, it knows that a new method ( public_images
was given a list of available methods for this example) was added.
class A & lt; Type string c 'c' end and # error: Super class mismatch for class A:
object
)
Comments
Post a Comment