Should this work?
Jacob Carlborg
doob at me.com
Thu Jan 9 23:44:54 PST 2014
On 2014-01-10 02:04, Jesse Phillips wrote:
> Interesting, I've had the opposite experience. I keep trying to perform
> range operations and C# doesn't have them. Slicing is of course ever
> more desired.
>
> That isn't to say C# is bad, but
>
> if(string.IsNullOrEmpty(str))
>
> vs
>
> if(str.empty)
>
> keeps throwing me off.
Or as in Ruby on Rails:
if str.blank?
end
"str" is conisderd blank if:
* it's nil (null)
* empty (its length is 0)
* it only contains whitespce
BTW, it works on all objects, not just strings. For arrays it will check
the length as well, but for other objects it will just check for nil.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list