Created
June 28, 2015 18:15
-
-
Save crguezl/c72b196ff3c170e138ff to your computer and use it in GitHub Desktop.
¿qué definición de C usará tutu, la de A o la de B?
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
=begin | |
Hola profesor, | |
Me ha surgido una duda con una pregunta: supongamos que la clase B hereda de A un método tutu que usa la constante C definida en A. Si en la clase B se define C, ¿qué definición de C usará tutu, la de A o la de B? | |
Un saludo. | |
=end | |
class A | |
C = 4 | |
def tutu | |
puts C | |
end | |
end | |
class B< A | |
C = 5 | |
end | |
B.new.tutu() | |
A.new.tutu() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment