From cb529cec8017593e842a600c4fb46d99077da533 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Mon, 9 May 2022 10:35:46 -0400 Subject: [PATCH 1/2] mention Ref for scalarizing a broadcast argument --- doc/src/manual/arrays.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/manual/arrays.md b/doc/src/manual/arrays.md index f6e4350726269..b8c4ee4e84ab0 100644 --- a/doc/src/manual/arrays.md +++ b/doc/src/manual/arrays.md @@ -1075,13 +1075,13 @@ julia> string.(1:3, ". ", ["First", "Second", "Third"]) ``` Sometimes, you want a container (like an array) that would normally participate in broadcast to be "protected" -from broadcast's behavior of iterating over all of its elements. By placing it inside another container -(like a single element [`Tuple`](@ref)) broadcast will treat it as a single value. +from broadcast's behavior of iterating over all of its elements. By placing it inside another container, +like a single element [`Tuple`](@ref) or a [`Ref`](@ref) (which acts like a 0-dimensional array), broadcast will treat it as a single value. ```jldoctest julia> ([1, 2, 3], [4, 5, 6]) .+ ([1, 2, 3],) ([2, 4, 6], [5, 7, 9]) -julia> ([1, 2, 3], [4, 5, 6]) .+ tuple([1, 2, 3]) +julia> ([1, 2, 3], [4, 5, 6]) .+ Ref([1, 2, 3]) ([2, 4, 6], [5, 7, 9]) ``` From bda53e6296360ba62919a059d956312a8635af11 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Mon, 9 May 2022 10:37:56 -0400 Subject: [PATCH 2/2] Update arrays.md --- doc/src/manual/arrays.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/manual/arrays.md b/doc/src/manual/arrays.md index b8c4ee4e84ab0..f5479e545abc2 100644 --- a/doc/src/manual/arrays.md +++ b/doc/src/manual/arrays.md @@ -1076,7 +1076,7 @@ julia> string.(1:3, ". ", ["First", "Second", "Third"]) Sometimes, you want a container (like an array) that would normally participate in broadcast to be "protected" from broadcast's behavior of iterating over all of its elements. By placing it inside another container, -like a single element [`Tuple`](@ref) or a [`Ref`](@ref) (which acts like a 0-dimensional array), broadcast will treat it as a single value. +like a single-element [`Tuple`](@ref) or a [`Ref`](@ref) (which acts like a 0-dimensional array), broadcast will treat it as a single value rather than as a container. ```jldoctest julia> ([1, 2, 3], [4, 5, 6]) .+ ([1, 2, 3],) ([2, 4, 6], [5, 7, 9])