# Meaning of ";" in PlotlyJS

I was always wondered what does “;” means in all examples.

The following functions give me the same output.

``````using PlotlyBase

function linescatter1()
trace1 = scatter(;x=1:4, y=[10, 15, 13, 17], mode="markers")
trace2 = scatter(;x=2:5, y=[16, 5, 11, 9], mode="lines")
trace3 = scatter(;x=1:4, y=[12, 9, 15, 12], mode="lines+markers")
Plot([trace1, trace2, trace3])
end

function linescatter2()
trace1 = scatter(x=1:4, y=[10, 15, 13, 17], mode="markers")
trace2 = scatter(x=2:5, y=[16, 5, 11, 9], mode="lines")
trace3 = scatter(x=1:4, y=[12, 9, 15, 12], mode="lines+markers")
Plot([trace1, trace2, trace3])
end

``````

I think it’s just function syntax for keyword parameters: Functions · The Julia Language
example:

``````julia> function t(; x = 1, y = 2 )
println(x,y)
end

julia> t(x=4,y=5)
45

julia> t(;x=4,y=5)
45
``````

You can omit the `; `

When the function is called, the semicolon is optional

1 Like

I see. But why should I use it? In other words, why all examples are written with “;” in function calls?

Perhaps to make it clear that these are keyword parameter? I don’t know, why is this important?

You don’t need it for keyword arguments, but you do need it for splatting keyword arguments.

1 Like

I was just looking for a reason why to use it.

Oh and you also need it when defining functions with keyword arguments. And for these reasons some people just always add them so they don’t have to think about it

Here’s two other cases where you would need to use `;`

If we define

``````kwargs = Dict(:x => 3, :y => 4)
foo(; x, y) = x + y # x and y are keyword arguments
``````

Then you need to use

``````foo(; kwargs...) # equivalent to foo(; x=3, y=4)
``````

``````foo(kwargs...) # equivalent to foo(x => 3, y => 4)
``````

Also with

``````bar = "baz"
foo(; bar) = println(bar)
``````

Then you want

``````foo(; bar) # equivalent to foo(bar=bar)
``````

``````foo(bar)