Access command line arguments in Julia

后端 未结 4 1590
别那么骄傲
别那么骄傲 2021-02-05 00:34

When I type in

$ julia myprog.jl foo bar baz

Where in my code can I go to access the strings \"foo\", \"bar\", \"baz\" ?

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-05 00:52

    A simpler example:

    #printargs.jl

    println(ARGS[2]);

    Run it as

    julia printargs.jl a b c d

    b

    Note that the array index starts from 1 and NOT 0. Thus ARGS[2] prints b and not c as in case of many other programming languages.

提交回复
热议问题