What is "Duck Typing" in Godot?

What is "Duck Typing" in Godot?

QueenOfSquiggles

1 год назад

649 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@johnnydessu
@johnnydessu - 25.01.2023 12:28

I can't even program my VCR back then, programming is far reach for me 😅 (half joke, half truth)

Ответить
@bodamat
@bodamat - 25.01.2023 14:20

In this case I like more C# because it more precise to types and can help me find error before running the project

Ответить
@ygorperez
@ygorperez - 26.01.2023 01:27

Good point, I hope these features come in the Godot 4.0 version alongside more typesafe features

Ответить
@collinvisser7108
@collinvisser7108 - 28.01.2023 09:53

Good visuals in the video.

Your video is fundamentally wrong about how duck typing works -
GDSCRIPT
First Duck typing is has_method it is away to detect before calling - to check if it quacks like a duck.
Second you cannot call a function that does not exist - I feel you Basie to C# is showing
at runtime the GDscript will will validate the calls and method and give error - Error Invalid call. Nonexistent function '' in class ''

in C# we use refection give some duck typing but interface are the correct way to create a contract between different objects.

in GDScript with can use duck type to leverage composition over inheritance (SOLID principle ) this make your code easy to read and modular. this can also be done in C# with interface. but in GDScript it is a lot easier as we can leverage the resource class and not have to worry about memory management and drag and drop in the UI.

Ответить
@lehisluguer9300
@lehisluguer9300 - 12.06.2024 20:11

You do have autocompletion in GDScript, as long as you specify the type of variables.. Statically Typed GDScript

Ответить