colours <- c("Red", "Blue", "Green", "Yellow")
printOption(colours, desc = "a colour") ## no return value
if (interactive()){
printOption(colours, desc = "a colour", match.ind = TRUE) # returns integer
printOption(colours, desc = "a colour", match.opt = TRUE) # returns character
}
Run the code above in your browser using DataLab