Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R equivalent of Python 'pass' statement

Tags:

r

Python has a pass statement, a null operation, which can be a useful placeholder before code is complete, for example in Python:

def example_function():
    pass
    # stuff to do here

Is there an equivalent in R? Thank you.

like image 533
Chris_Rands Avatar asked Aug 15 '16 12:08

Chris_Rands


People also ask

What is the pass statement in Python?

Python pass Statement The pass statement is used as a placeholder for future code. When the pass statement is executed, nothing happens, but you avoid getting an error when empty code is not allowed. Empty code is not allowed in loops, function definitions, class definitions, or in if statements.

Is pass the same as return in Python?

Return exits the current function or method. Pass is a null operation and allows execution to continue at the next statement.

Is pass a keyword in Python?

In Python, the pass keyword is an entire statement in itself. This statement doesn't do anything: it's discarded during the byte-compile phase. But for a statement that does nothing, the Python pass statement is surprisingly useful. Sometimes pass is useful in the final code that runs in production.

What is the equivalent of pass in Javascript?

Python's pass mainly exists because in Python whitespace matters within a block. In Javascript, the equivalent would be putting nothing within the block, i.e. {} .


1 Answers

Just have an empty function body:

foo = function(){
 }

You should probably also add a comment, and a warning maybe?

foo = function(){
# write this tomorrow
 warning("You ran foo and I havent written it yet")
}

Same thing with an if expression:

if(x==1){
  # do this bit later
  }else{
  message("x isnt 1")
}
like image 116
Spacedman Avatar answered Sep 28 '22 06:09

Spacedman