Empty string: Difference between revisions

Content added Content deleted
(add Ruby)
Line 336:
s.each_char.to_a.empty?</lang>
 
Non-empty expressions, in addition to simply negating the above expressions:
<lang ruby>s != ""
s.length > 0
s[/./]</lang>
 
Note that we cannotcan '''not''' do the following, because the empty string is equivalent to true in Ruby ([[Boolean values#Ruby]]):
<lang ruby>if s then puts "not empty" end</lang>