wheineman / nrpl

Nim REPL
MIT License
56 stars 9 forks source link

Methods on sequences not working #3

Closed xhevahir closed 9 years ago

xhevahir commented 9 years ago

I'm going through the examples in Learn Nim in Y Minutes and it doesn't seem possible to make any changes to a sequence defined in nrpl:

var drinks: seq[string] drinks = @["Water", "Juice", "Chocolate"] drinks.add("Milk") echo(drinks) @[Water, Juice, Chocolate]

wheineman commented 9 years ago

Fixed in the most recent version:

$ nrpl
> var
-   drinks: seq[string]
-
> drinks = @["Water", "Juice", "Chocolate"]
> drinks.add("Milk")
> echo(drinks)
@[Water, Juice, Chocolate, Milk]

Note that in the above I left deferred execution mode after defining the drinks variable. I could have remained in deferred execution mode until just before the echo command and gotten the same result:

$ nrpl
> var
-   drinks: seq[string]
- drinks = @["Water", "Juice", "Chocolate"]
- drinks.add("Milk")
-
> echo(drinks)
@[Water, Juice, Chocolate, Milk]

Until I can figure out how to automatically move between deferred and immediate execution modes users will have to be aware of what mode is current by watching the prompt and use of the ":history" and ":clear" immediate commands.