Skip to content

Document uses  #1

@ctbrown

Description

@ctbrown

An interesting use of backpipe is when it is used to clear some clutter. Two uses come to mind.

  • Defining S4 Methods : reduces clutter associated with bracketings
  • Using logging : Put the logging command first so that it is easy to see.

This makes them more like the way that if works.

#' ## S4 Methods
setMethod( "cx", signature("character","character"), . ) %:% 
  function(x,y) { print("hw") } 

#' ## Logging
 warn %:% "This is not a love song"

There are some variants of this. For example, you could backwardly create a list of arguments that are then passed to the first argument ... always a function.

warn %:% "you've been warned" %:% immediate=TRUE 

Even better if we can give it a special operator:

warn : "you've been warned" 

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