2

Found in roxygen2 code the shortcut :

%||%

No help can be found with

?"%||%"

It looks like a shortcut for union() but how could I display it's definition ?

cmbarbu
  • 4,354
  • 25
  • 45
  • 2
    You'll find such constructs throughout Hadley's (and other folks') packages, too. Highly efficient syntax shortcuts. Def worth digging. You can also find out where that's defined in any installed pacakges via `getAnywhere("%||%")` and then see the source for any of them by indexing that with `[]` (i.e. `getAnywhere("%||%")[1]`). In this case they all define it the same way, but it may not be the case in all packages. I know you only needed to see the definition from `roxygen2` ;-) – hrbrmstr Oct 06 '15 at 12:03
  • 1
    Take a look [here](http://stackoverflow.com/questions/19226816/how-can-i-view-the-source-code-for-a-function) for such questions in general – David Arenburg Oct 06 '15 at 12:11

1 Answers1

4

From source (utils.R from roxygen2_4.1.1.tar.gz)

"%||%" <- function(a, b) {
  if (!is.null(a)) a else b
}
rbm
  • 3,243
  • 2
  • 17
  • 28
  • 2
    (i hope this is trivial, but just in case: if `a` is not null, then return `a` otherwise return `b`) – rbm Oct 06 '15 at 12:01