Created
April 23, 2017 01:25
-
-
Save fcamel/a1d0f1bfcf7672ee162edab3464fd8ae to your computer and use it in GitHub Desktop.
ruby, python, comparison of redefining class
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
$ cat a.py | |
class A(object): | |
def foo(self): | |
return "foo" | |
a = A() | |
print a.foo() | |
class A(object): | |
def foo(self): | |
return "bar" | |
print a.foo() | |
$ python a.py | |
foo | |
foo | |
$ cat a.rb | |
class A | |
def foo | |
return "foo" | |
end | |
end | |
a = A.new | |
print a.foo(), "\n" | |
class A | |
def foo | |
return "bar" | |
end | |
end | |
print a.foo(), "\n" | |
$ ruby a.rb | |
foo | |
bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment