What is meaning of the syntax %||%?

前端 未结 2 1589
臣服心动
臣服心动 2021-01-28 14:36

I\'m trying to create a dynamic UI, so i used this code

output$col <- renderUI({
    map(col_names(), ~ textInput(.x, NULL, value = isolate(input[[.x]])) %||         


        
2条回答
  •  逝去的感伤
    2021-01-28 14:56

    The %||% comes from rlang. You can find it on the ?"op-null-default" help page. From the documentation

    This infix function makes it easy to replace NULLs with a default value. It's inspired by the way that Ruby's or operation (||) works.

    Basically it returns the second value if the first is NULL.

提交回复
热议问题