In order to understand how the dot operator (.) works, it is best to study the possible results from different ways of applying to broadcast to rand(length(x)) in our preceding example:
- Case 1: Not broadcasting rand(length(x))—in this case, the result is a 10-element Vector{Float64}.
- Case 2: Broadcasting the rand.(length(x)) outer function—in this case, the result is also a 10-element Vector{Float64}. The reason for this is that rand.(length(x)) is rewritten by Julia to something similar to broadcast(v -> rand(v), length(x)), and because we are effectively broadcasting over one element where length(x) is 10, and nothing changes.
- Case 3: Broadcasting the rand(length.(x)) inner function—in this case, the result is 1. This ...