-
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rdmd:
--loop
and --eval
with a last statement without effect shou…
…ld print it
- Loading branch information
Showing
3 changed files
with
94 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
In rdmd `--eval` and `--loop` the last statement without effect will be printed | ||
|
||
`--eval` and `--loop` are two convenience features of `rdmd` that allow quick experimentation with D code. | ||
However, until | ||
|
||
$(CONSOLE | ||
rdmd --eval='"hello"' | ||
/tmp/.rdmd-1000/eval.CFD785092747553A81673B51A318D6AE.d(18): $(RED Error): "hello" has no effect | ||
) | ||
|
||
The new behavior will default to writeln if the last statement would have no effect: | ||
|
||
$(CONSOLE | ||
rdmd --eval="hello" | ||
hello | ||
) | ||
|
||
A few more examples of `rdmd` in action: | ||
|
||
$(H4 Use `rdmd` as your calculator) | ||
|
||
$(CONSOLE | ||
rdmd --eval="2 + 2" | ||
4 | ||
) | ||
|
||
$(CONSOLE | ||
rdmd --eval="2.pow(4)" | ||
16 | ||
) | ||
|
||
$(H4 Select the first column in a CSV file) | ||
|
||
$(CONSOLE | ||
rdmd --loop='line.splitter(",").take(1)' | ||
16 | ||
) | ||
|
||
$(H4 Use `rdmd` as drop-in for Unix tools) | ||
|
||
$(CONSOLE | ||
seq 5 | rdmd --loop='stdin.byLine.drop(2).joiner(newline)' | ||
2 | ||
3 | ||
4 | ||
5 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters