Array Methods Work on NON-Arrays?!

Array methods are DECEPTIVE! They work on any object with length property. This object isn't an array, but map() works on it! JavaScript lies about types!

#javascript #javascripttricks #arraymethods #arraylikeobjects #typecoercion #javascriptweird #javascriptquiz #codingchallenge #javascriptshorts #javascriptwtf #ducktyping #advancedjavascript

https://www.youtube.com/watch?v=7Kc8hvaE580

Array Methods Work on NON-Arrays?! #typecoercion

YouTube
Protokoły w Pythonie - Jan "Niedźwiedź" Sikorski

“Daję słowo, zatem ja już przeszło czterdzieści lat mówię prozą, nie mając o tem żywnego pojęcia! Jestem panu najszczerzej obowiązany, żeś mnie pouczył.” –Mo...

To be precise, 3 bad rows out of 600M...

#ducktyping - talk to your kids about it before someone else does.

What's in a name? That which we call a duck
By any other name would quack the same;
So a sequence would, were it not a sequence call'd,
Retain that dear iterability which it bears
Without that title. Sequence, doff thy name,
And for that name which is no part of thee
give thy iterator to me.

#Python #DuckTyping

Checking for an empty list in Python - Python Morsels (@treyhunner)

Various methods to check if a list is empty in Python:
➡️ checking the list's length,
➡️ evaluating the list's truthiness
➡️ comparing the list to another empty list

#Python #Truthiness #PEP8 #DuckTyping #Programming #PythonProgramming

https://www.pythonmorsels.com/checking-for-an-empty-list-in-python/

Checking for an empty list in Python

Python programmers typically check for empty lists by relying on truthiness.

Another duck-typing 🦆 post. A few days ago, I covered the GetAwaiter method that allows adding await functionality to any type. Today, another feature that relies on the same construct.

Deconstruction is a feature that allows extracting separate values out of a tuple. But what if we would like to deconstruct a type that is a bit more complex than a tuple? We can do it with the help of duck typing.

Deconstruction will work if the compiler detects a Deconstruct method that matches the call that we are trying to make. For example, let's try to deconstruct a Process. See the example below.

We start the process and wait for it to exit. In 1️⃣, we would like to use deconstruction to assign Pid & ExitCode to two variables. It won't work out of the box. But we can write an extension method 2️⃣ that the compiler would be able to use to perform the deconstruction.

Docs 📑: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/functional/deconstruct

#dotnet #ducktyping #deconstruct

Deconstructing tuples and other types - C#

Learn how to deconstruct tuples and other types.

Turns out duck typing is actually a way you can draw ducks with code: #DuckTyping #BingAI #Bing

@chaotin “Well if it smells like lemon cake and tastes a bit sour… 🤷‍♂️”

#ducktyping

#DuckTyping : when you can't formalize a relationship between T and F