Skip to content

Syntax for rx_or() #16

@dmi3kno

Description

@dmi3kno

Right now we have rx_or implementation which compares .data and value

##### Do not run
rx() %>% 
  rx_find("a") %>%
  rx_or("b") # or at best rx_or(rx_find("b"))

In the comments you mentioned:

##### Do not run
  # Not sure if I like this. I would prefer:
  # find(value = "foo") %>%
  #   or() %>%
  #   find("bar")
  # Rather than having to nest a rule inside of or(), maybe use glue?

Might the solution be similar to how now (in dev branch) we organized rx_one_of():

###### Do not run
rx() %>%
  rx_find("gr") %>%
  either_of(rx_find("a"), rx_find("e")) %>%
  rx_find("y")

In a sense, this is rx_one_of with (?:a|b) instead of [ab] and limited to two arguments only. I actually believe nothing prevents us from allowing more arguments, if we go down this route. I think going this route will add consistency to the package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions