Python is not typed and still you can use generics!

Python Generics ⇢ Make FirstOrDefault method with type hints.

The FirstOrDefault method in C# returns the first element from a list that satisfies a predicate, or returns the type default value. This can work because C# lists are generic. Python is not typed and still you can use generics and in this video, you learn how to create a generic first_or_default method in Python

Written by Loek van den Ouweland on 2024-01-24.
Questions regarding this artice? You can send them to the address below.