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.
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.
Return exits the current function or method. Pass is a null operation and allows execution to continue at the next statement.
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.
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. {} .
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")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With