Empty string: Difference between revisions

Content added Content deleted
(→‎{{header|Go}}: mention Go zero value initialization; show len(s))
(jq)
Line 556: Line 556:
s.length > 0
s.length > 0
Boolean(s)</lang>
Boolean(s)</lang>

=={{header|jq}}==
jq strings are JSON strings. The empty string literal is simply <tt>""</tt>.

If s is a string or an array, then the additive "zero" for s can be created as s[0:0]. That is, if s is a string, then s[0:0] will yield the empty string. This is useful when writing polymorphic functions.

To determine whether a string, s, is empty:<lang jq>s == ""
# or:
s|length == 0
</lang>

To determine whether a string, s, is non-empty:<lang jq>s != ""
# or:
s.length != 0 # etc.</lang>


=={{header|K}}==
=={{header|K}}==