Empty string: Difference between revisions
Content added Content deleted
Line 1,096: | Line 1,096: | ||
s != "" |
s != "" |
||
len(s) != 0 // or > 0</lang> |
len(s) != 0 // or > 0</lang> |
||
::<lang go>package main |
|||
import ( |
|||
"fmt" |
|||
) |
|||
func test(s string) { |
|||
if len(s) == 0 { |
|||
fmt.Println("empty") |
|||
} else { |
|||
fmt.Println("not empty") |
|||
} |
|||
} |
|||
func main() { |
|||
// Demonstrate how to assign an empty string to a variable. |
|||
str1 := "" |
|||
str2 := " " |
|||
// check if a string or []string is empty. |
|||
test(str1) // prt empty |
|||
// Demonstrate how to check that a string is not empty. |
|||
test(str2) // prt not empty |
|||
}</lang> |
|||
=={{header|Groovy}}== |
=={{header|Groovy}}== |