I am a newer to Nim programing language. when I use Python, I can use the 'pass' to skip the defination detail of a function and class.
def foo():
pass # skip detail
class Bar():
pass
Is there are something like this in Nim?
With Python >= 3.0, you should use ... (Ellipsis) instead of pass to indicate "finish later" blocks.
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.
Yes, you can/should remove them because they do nothing. The Python community teaches "explicit is better than implicit" as long as the explicit code does something useful. Those else: pass 's however contribute nothing positive to the code.
In Python programming, the pass statement is a null statement. The difference between a comment and a pass statement in Python is that while the interpreter ignores a comment entirely, pass is not ignored. However, nothing happens when the pass is executed. It results in no operation (NOP).
discard
does the same in Nim:
proc foo =
discard # skip detail
type Bar = object
For objects it's not even necessary, but possible, to specify discard
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