Strings are scalars for the purposes of broadcasting, so "abc" .|> x->println(x) and "abc" |> x->println(x) do the same thing and they both call println on the entire string a single time. If you want to broadcast over the characters of a string, you need to collect it first: collect("abc") .|> x->println(x). However, this is an antipattern because you are using broadcasting for a side-effect and uselessly constructing a vector of nothing values. Consider doing foreach(println, "abc") instead. The foreach function doesn’t need to guess what is a scalar or not, it only makes sense to apply it to something iterable.
3 Likes