The REPL & Your First Program
Useful: Tab completion (also for Unicode: \alpha<Tab> → α), @doc, apropos("sort"), methods(+), @which 1 + 2, @edit sum([1]), varinfo(), versioninfo().
3.1 REPL modes
default / Backspace Useful: Tab completion (also for Unicode: \alpha<Tab> → α), @doc, apropos("sort"), methods(+), @which 1 + 2, @edit sum([1]), varinfo(), versioninfo().
Revise.jl automatically reloads code changes in a running session — install it and put using Revise in ~/.julia/config/startup.jl.
julia> 1 + 2
3
julia> ans * 10 # `ans` holds the last result
30
help?> println # documentation
shell> ls # run a shell command
pkg> add Plots # install a package
julia> exit() # or Ctrl+D3.2 Hello World
A script with a main function and arguments:
Julia 1.11+ also supports function (@main)(args) as an explicit entry point.
println("Hello, World!")julia hello.jlfunction main(args)
name = isempty(args) ? "World" : args[1]
println("Hello, $name!")
end
main(ARGS)3.3 Comments
# Single-line comment
#=
Multi-line comment
#= can be nested =#
=#
"""
myfunc(x)
Docstring placed before a definition.
"""
myfunc(x) = x