Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Empty-string/V-(Vlang)/empty-string-1.v
Normal file
13
Task/Empty-string/V-(Vlang)/empty-string-1.v
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// define and initialize an empty string
|
||||
mut s := ""
|
||||
|
||||
// assign an empty string to a variable
|
||||
s = ""
|
||||
|
||||
// check that a string is empty, any of:
|
||||
s == ""
|
||||
s.len() == 0
|
||||
|
||||
// check that a string is not empty, any of:
|
||||
s != ""
|
||||
s.len() != 0 // or > 0
|
||||
17
Task/Empty-string/V-(Vlang)/empty-string-2.v
Normal file
17
Task/Empty-string/V-(Vlang)/empty-string-2.v
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
fn test(s string) {
|
||||
if s.len() == 0 {
|
||||
println("empty")
|
||||
} else {
|
||||
println("not empty")
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue