What are Symbols for?

Today I came across the Symbol type, but I don’t understand what it’s for. The online documenation offers these two examples:

julia> :name
:name

julia> typeof(:name)
Symbol

julia> x = 42
42

julia> eval(:x)
42

and when I search the help menu in the REPL I see these two examples:

  julia> Symbol("my", "name")
  :myname
  
  julia> Symbol("day", 4)
  :day4

All of the examples above show syntax, but it’s unclear when any of the cases above might be useful for anything.

When might anyone ever use :myname or :day4 or eval(:x)?

1 Like

check this out, it is a good overview What is a "symbol" in Julia? - Stack Overflow

8 Likes