I was looking around to see if there was a way to test if a ruby object was nil or empty in one test. Something like a nempty?
(it's a working title of the function)
Turns out there is, called blank?
, which returns true if something is an empty string, nil, and empty object, an empty array or one or many spaces.
This is implemented by overloading the String class. In Ruby on Rails.
See, it's not a ruby method, it's a Rails method. Something that could be used in the wider community (other examples include titleize
) but have been implemented in one library, which is gargantuan enough.
Surely others have ported this logic to helper gems, but it's just annoying to see such "vendor lock-in"(?) around in places that means it's harder to leave the ecosystem and just to the raw language constructs.
Or is this just a bunch of people creating helper functions in a much more accessible ecosystem? (Rails, with a presumably easier upgrade path (CVE's, anyone) vs Ruby itself, which has its whole 1.8 vs 1.9.x vs 2.x issues)