Jump to content

Empty string: Difference between revisions

Line 1,096:
s != ""
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}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.