What are braces used for in Julia

I see braces used in various ways in Julia but I’m not quite sure what they are for. Here is one instance but I’ve also seen them seem to be for types. And kind of hard to find in the documentation.

Dict{String, Vector{T} where T} with 2 entries:
“first name” => [“Rohit”, “Rahul”, “Akshat”]
“customer age” => [15, 20, 25]

2 Likes

Type parameters are introduced immediately after the type name, surrounded by curly braces

https://docs.julialang.org/en/v1/manual/types/#Parametric-Types

The manual has a lot of good material for getting started.

Also note that while { } outside type parameters are not assigned syntax, they parse perfectly fine, so you can use them in macros. See eg

https://kristofferc.github.io/PGFPlotsX.jl/v1/man/options.html

1 Like