Skip to content

Commit 2edec09

Browse files
tpappmbauman
andcommitted
Document the role of Ref in broadcasting. (#32645)
* Document the role of Ref in broadcasting. * replace with a more relevant example * Update base/refpointer.jl Co-Authored-By: Matt Bauman <[email protected]>
1 parent ad8cf8d commit 2edec09

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

base/refpointer.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,19 @@ it can be written `Ref(a, i)` for creating a reference to the `i`-th element of
1616
When passed as a `ccall` argument (either as a `Ptr` or `Ref` type), a `Ref` object will be
1717
converted to a native pointer to the data it references.
1818
19-
There is no invalid (NULL) `Ref` in Julia, but a `C_NULL` instance of `Ptr` can be passed to a `ccall` Ref argument.
19+
There is no invalid (NULL) `Ref` in Julia, but a `C_NULL` instance of `Ptr` can be passed to
20+
a `ccall` Ref argument.
21+
22+
# Use in broadcasting
23+
24+
Broadcasting with `Ref(x)` treats `x` as a scalar:
25+
```jldoctest
26+
julia> isa.(Ref([1,2,3]), [Array, Dict, Int])
27+
3-element BitArray{1}:
28+
1
29+
0
30+
0
31+
```
2032
"""
2133
Ref
2234

0 commit comments

Comments
 (0)