Clearly, switch("d", a = 1, b = 2)
does not have a default value, a value matching "d", or any reason to return anything. The documentation for switch
tells us that "A warning is signaled if no alternatives are provided, as this is usually a coding error". However, when I run switch("d", a = 1, b = 2)
, nothing happens at all. I get no outputs, warnings, or errors. What have I misunderstood about R's switch
? I expected a warning.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…