{ "uuid": [ { "value": "aa72d773-765e-42bb-bf5b-f070a97f5884" } ], "langcode": [ { "value": "en" } ], "type": [ { "target_id": "daily_email", "target_type": "node_type", "target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7" } ], "revision_timestamp": [ { "value": "2025-05-11T09:00:50+00:00" } ], "revision_uid": [ { "target_type": "user", "target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849" } ], "revision_log": [], "status": [ { "value": true } ], "uid": [ { "target_type": "user", "target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849" } ], "title": [ { "value": "Duck typing\n" } ], "created": [ { "value": "2022-12-21T00:00:00+00:00" } ], "changed": [ { "value": "2025-05-11T09:00:50+00:00" } ], "promote": [ { "value": false } ], "sticky": [ { "value": false } ], "default_langcode": [ { "value": true } ], "revision_translation_affected": [ { "value": true } ], "path": [ { "alias": "\/daily\/2022\/12\/21\/duck-typing", "langcode": "en" } ], "body": [ { "value": "\n
If it looks like a duck, walks like a duck, and quacks like a duck, it must be a duck.<\/p>\n\n
If I pass a parameter into a function, as long as it works with the code within the function - it is of the correct type and has the expected properties and methods - it will work, although nothing is enforcing that the correct thing is passed in.<\/p>\n\n
If not, you'd get an error that the method or property doesn't exist when trying to invoke or access it.<\/p>\n\n
This is the opposite of strict typing, where you'd get a Type error if you passed the wrong thing.<\/p>\n\n
Both are valid approaches, though I prefer to use types and get specific error messages and leverage tools like static analysis, which work better the more it understands your code.<\/p>\n\n
In particular when writing and using open-source code that anyone can use however they like, I'd suggest leveraging types and type-checking, but it depends on what you, your team or your community prefer.<\/p>\n\n ", "format": "full_html", "processed": "\n
If it looks like a duck, walks like a duck, and quacks like a duck, it must be a duck.<\/p>\n\n
If I pass a parameter into a function, as long as it works with the code within the function - it is of the correct type and has the expected properties and methods - it will work, although nothing is enforcing that the correct thing is passed in.<\/p>\n\n
If not, you'd get an error that the method or property doesn't exist when trying to invoke or access it.<\/p>\n\n
This is the opposite of strict typing, where you'd get a Type error if you passed the wrong thing.<\/p>\n\n
Both are valid approaches, though I prefer to use types and get specific error messages and leverage tools like static analysis, which work better the more it understands your code.<\/p>\n\n
In particular when writing and using open-source code that anyone can use however they like, I'd suggest leveraging types and type-checking, but it depends on what you, your team or your community prefer.<\/p>\n\n ", "summary": null } ] }