Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there are something like Python's 'pass' statement in Nim

Tags:

nim-lang

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?

like image 777
PKT233 Avatar asked Jan 16 '18 13:01

PKT233


People also ask

What can I use instead of pass in Python?

With Python >= 3.0, you should use ... (Ellipsis) instead of pass to indicate "finish later" blocks.

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.

Can I use pass in an else statement Python?

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.

What is the difference between a comment and a pass statement in Python?

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).


1 Answers

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

like image 152
def- Avatar answered Oct 12 '22 00:10

def-