Skip to content

Instantly share code, notes, and snippets.

@crguezl
Created June 28, 2015 18:15
Show Gist options
  • Save crguezl/c72b196ff3c170e138ff to your computer and use it in GitHub Desktop.
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?
=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