3 ms·
Coming from Ruby, I encountered this funny situation in Python. I was looking how to get first element of an array or get nil if the array is empty. Python li
by tanin 8y ago
Coming from Ruby, I encountered this funny situation in Python.
I was looking how to get first element of an array or get nil if the array is empty.
Python library doesn't provide this kind of functionality.
https://stackoverflow.com/questions/363944/python-idiom-to-return-first-item-or-none https://stackoverflow.com/questions/363944/python-idiom-to-r... offers multiple ugly ways of doing it.
For Ruby, we use `.first`.
In Ruby, the standard library is richer. A lot of libraries are "official" because Rails uses it.