Shouldnt all strings have a value or something the says it could be empty or it might have a value. But making it empty isnt that wrong? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Shouldnt all strings have a value or something the says it could be empty or it might have a value. But making it empty isnt that wrong?

Value of strings

9th Mar 2017, 6:12 PM
Raheem Steward
Raheem Steward - avatar
2 Answers
+ 2
No, that isn't wrong. But you can also assign null to a string variable.
9th Mar 2017, 8:44 PM
Mohamad Abdelhafiz
Mohamad Abdelhafiz - avatar
+ 1
You have to remember the 'truthy/falsey' nature of languages. In Swift, I believe it's like Ruby in that only nil and false are falsey. Every other type is inherently truthy. http://khanlou.com/2016/06/falsiness-in-swift/
9th Mar 2017, 11:27 PM
Joel Hager
Joel Hager - avatar