The string.empty?
function in Ruby returns a true
value if the string is empty; otherwise, it returns false
.
Figure 1 shows the visual representation of the string.empty?
function.
string_name.empty?
# string_name is the name of the string
This function does not require a parameter.
If the string is empty, the string.empty?
function returns a true
value. Otherwise, it returns false
.
The following code widget shows how the string.empty?
function is used.
# string with valuestr_1='Hello'print "The string1('Hello') is empty : ", str_1.empty?, "\n"# empty stringstr_2 = ''print "The string2('') is empty : ", str_2.empty?, "\n"