x <- switch(1,"hi","sec","thr") #here 1 vl return the first position value following 1
print(x)
#output is [1] "hi"
x <- switch(0,"first","sec","thr") #here 0 vl return the zero position value i.e there is no value at zero so it vl return nul
print(x)
#output is NULL
x <- switch(2,"name" = name<- readline(prompt = "enter name"),"c","thr")
print(x)
#output is [1] "c"
print(x)
#output is [1] "hi"
x <- switch(0,"first","sec","thr") #here 0 vl return the zero position value i.e there is no value at zero so it vl return nul
print(x)
#output is NULL
x <- switch(2,"name" = name<- readline(prompt = "enter name"),"c","thr")
print(x)
#output is [1] "c"