What does it mean x=-3:0.1:3?

This is shorthand notation for a range from -3 to 3 (inclusive), with steps of size 0.1, i.e.:

julia> collect(-3:0.1:3)
61-element Vector{Float64}:
 -3.0
 -2.9
 -2.8
 -2.7
  ⋮
  2.7
  2.8
  2.9
  3.0

Here, I’ve used collect to create a vector with every element of the range in it, however most of the time you don’t actually need to do this - it is more efficient to just work with the range, which only stores start and end point and stepsize:

julia> fieldnames(typeof(-3.0:0.1:3.0))
(:ref, :step, :len, :offset)

This allows you to create very large ranges at no extra cost:

julia> x = 1e10:0.1:1e15
1.0e10:0.1:1.0e15

julia> length(x)
9999900000000001

Here I’ve created a range that holds way more elements than I could fit in memory as Float64 - if I need any of them, they will be calculated on the fly:

julia> x[1_234_456_789]
1.01234456788e10
5 Likes