implemented 'let' statement
This commit is contained in:
parent
31a994cc10
commit
7fcbdc6d42
33 changed files with 169 additions and 103 deletions
11
tests/reject/tlet.nim
Normal file
11
tests/reject/tlet.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
discard """
|
||||
line: "10"
|
||||
errormsg: "'name' cannot be assigned to"
|
||||
"""
|
||||
|
||||
Echo("What's your name? ")
|
||||
let name = readLine(stdin)
|
||||
while name == "":
|
||||
Echo("Please tell me your name: ")
|
||||
name = readLine(stdin)
|
||||
|
||||
16
tests/reject/tlet2.nim
Normal file
16
tests/reject/tlet2.nim
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
discard """
|
||||
line: "13"
|
||||
errormsg: "for a 'var' type a variable needs to be passed"
|
||||
"""
|
||||
|
||||
proc divmod(a, b: int, res, remainder: var int) =
|
||||
res = a div b # integer division
|
||||
remainder = a mod b # integer modulo operation
|
||||
|
||||
let
|
||||
x = 9
|
||||
y = 3
|
||||
divmod(8, 5, x, y) # modifies x and y
|
||||
echo(x)
|
||||
echo(y)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue