amayne / SwiftString

A comprehensive, lightweight string extension for Swift
MIT License
1.62k stars 141 forks source link

"".isEmpty != "".isEmpty() #8

Closed ZeroFactor closed 8 years ago

ZeroFactor commented 8 years ago

If this was intentional could someone add something to the documentation about why?

waterskier2007 commented 8 years ago

Do you mean the syntax or the actual value, because the syntax cannot be .isEmpty as that would be a redeclaration of the existing .isEmpty in swift. The difference between isEmpty in swift and this .isEmpty() is that .isEmpty() will trim whitespace and newline characters before testing if the string is empty, whereas Swift's .isEmpty will not.

Swift would return false for

" ".isEmpty

ZeroFactor commented 8 years ago

I should have been more clear.

I was expecting "".isEmpty() to be true, but it is false. If it was true, this could be a nice replacement for String.isEmpty. Instead it seems like it is intended to detect if the string has content and that all of the content is whitespace.

waterskier2007 commented 8 years ago

That makes sense. I'll add a fix for that to my currently open pull request

amayne commented 8 years ago

Thanks! Merged in