Last active
December 18, 2021 18:23
-
-
Save MarkCLewis/fadd2aea91f221264de806a567f95069 to your computer and use it in GitHub Desktop.
Class Error Comparison (dynamics vs. static)
This file contains 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
import math | |
class Person: | |
age = 5 | |
name = 'hi' | |
def birthday(self): | |
self.age += 1 | |
return self.age | |
p = Person() | |
print(p.age) | |
print(p.birthday()) | |
# change of name | |
p.names = 'there' | |
print(p.name) | |
print(math.sqrt(9)) | |
math.sqrt = lambda n: 2*n | |
print(math.sqrt(9)) |
This file contains 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
class Person: | |
var age = 5 | |
var name = "hi" | |
def birthday(): Int = | |
age += 1 | |
age | |
@main def start = | |
val p = Person() | |
println(p.age) | |
println(p.birthday()) | |
// change of name | |
p.names = "there" | |
println(p.name) | |
println(math.sqrt(9)) | |
math.sqrt = (n: Double) => 2 * n | |
println(math.sqrt(9)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment