Skip to content

Instantly share code, notes, and snippets.

@MarkCLewis
Last active December 18, 2021 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkCLewis/fadd2aea91f221264de806a567f95069 to your computer and use it in GitHub Desktop.
Save MarkCLewis/fadd2aea91f221264de806a567f95069 to your computer and use it in GitHub Desktop.
Class Error Comparison (dynamics vs. static)
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))
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