class.gd 568 B

12345678910111213141516171819202122232425
  1. # Test non-nested/slightly nested class architecture.
  2. class Test:
  3. var number = 25
  4. var string = "hello"
  5. class TestSub extends Test:
  6. var other_string = "bye"
  7. class TestConstructor:
  8. func _init(argument = 10):
  9. print(str("constructor with argument ", argument))
  10. func test():
  11. var test_instance = Test.new()
  12. test_instance.number = 42
  13. var test_sub = TestSub.new()
  14. assert(test_sub.number == 25) # From Test.
  15. assert(test_sub.other_string == "bye") # From TestSub.
  16. var _test_constructor = TestConstructor.new()
  17. _test_constructor = TestConstructor.new(500)