RosettaCodeData/Task/Empty-string/V-(Vlang)/empty-string-2.v

18 lines
344 B
Coq
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
fn test(s string) {
2026-02-01 16:33:20 -08:00
if s.len() == 0 {
println("empty")
} else {
println("not empty")
}
2023-07-01 11:58:00 -04:00
}
fn main() {
2026-02-01 16:33:20 -08:00
// assign an empty string to a variable.
str1 := ""
str2 := " "
// check if a string is empty.
test(str1) // prt empty
// check that a string is not empty.
test(str2) // prt not empty
2023-07-01 11:58:00 -04:00
}