Skip to content

Behavior of Ref in broadcast #24880

Closed
Closed
@goretkin

Description

@goretkin

I understand Ref as a length-1 array (tell me how flawed this is), but that's not how it behaves in a broadcast. From the discussion at https://discourse.julialang.org/t/broadcasting-and-arrays-of-arrays/7444/5 :

julia> [1, 2] .- Ref([1, 2])  # behaves like [1, 2] .- [1]
2-element Array{Int64,1}:
 0
 1

julia> [1, 2] .- [[1, 2]]
2-element Array{Array{Int64,1},1}:
 [0, -1]
 [1, 0] 

(thanks @rdeits )

Metadata

Metadata

Assignees

No one assigned

    Labels

    broadcastApplying a function over a collection

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions