# Dot syntax with tuples

**URL:** <https://discourse.julialang.org/t/dot-syntax-with-tuples/15222>\
**Category:** General Usage\
**Created:** [September 20, 2018, 10:31am UTC](https://discourse.julialang.org/t/dot-syntax-with-tuples/15222 "2018-09-20T10:31:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nantonel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nantonel/32/2889_2.png) [@nantonel](https://discourse.julialang.org/u/nantonel)\
**Post date:** [September 20, 2018, 10:31am UTC](https://discourse.julialang.org/t/dot-syntax-with-tuples/15222/1 "2018-09-20T10:31:30Z")

</div>

In Julia 0.6 the it was possible to do:

```julia
julia> x = ones(2), zeros(3,4);

julia> x .+ 3
([4.0, 4.0], [3.0 3.0 3.0 3.0; 3.0 3.0 3.0 3.0; 3.0 3.0 3.0 3.0])

```

Now in 1.0 this is no longer possible:

```julia

julia> x .+ 3
ERROR: MethodError: no method matching +(::Array{Float64,1}, ::Int64)

```

Is there an elegant syntax to do this in 1.0?

Possibly I would prefer avoiding something like:

```julia
julia> ([xi.+3 for xi in x]...,)
([4.0, 4.0], [3.0 3.0 3.0 3.0; 3.0 3.0 3.0 3.0; 3.0 3.0 3.0 3.0])

```

since I would like `x` to be either an `Array` or a `Tuple` of `Array`s.  
I thank you!

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [September 20, 2018, 10:41am UTC](https://discourse.julialang.org/t/dot-syntax-with-tuples/15222/2 "2018-09-20T10:41:35Z")

</div>

You can broadcast a broadcasted function:

```julia
julia> (x -> x .+ 3).(x)
([4.0, 4.0], [3.0 3.0 3.0 3.0; 3.0 3.0 3.0 3.0; 3.0 3.0 3.0 3.0])

```

See also [Nested . syntax · Issue #20502 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/20502), [Recursive broadcast · Issue #22622 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/22622)

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [September 20, 2018, 8:25pm UTC](https://discourse.julialang.org/t/dot-syntax-with-tuples/15222/3 "2018-09-20T20:25:36Z")

</div>

You can still get the recursive broadcast as 0.6 like this:

```julia
julia> +ᵥ(x,y) = x .+ y
+ᵥ (generic function with 1 method)

julia> x = ones(2), zeros(3,4)
([1.0, 1.0], [0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0])

julia> x .+ᵥ 3
([4.0, 4.0], [3.0 3.0 3.0 3.0; 3.0 3.0 3.0 3.0; 3.0 3.0 3.0 3.0])

```

---

<div class="post-metadata">

**Author:** ![Jon\_Norberg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jon_norberg/32/3218_2.png) [@Jon\_Norberg](https://discourse.julialang.org/u/Jon_Norberg)\
**Post date:** [December 11, 2019, 6:14am UTC](https://discourse.julialang.org/t/dot-syntax-with-tuples/15222/4 "2019-12-11T06:14:01Z")

</div>

Is there any recommended (pretty) way to solve broadcast with tuples like

```julia
x=(a=2,b=3); y=rand(10)
f(y,x)=(y+x.a)*x.b
f.(y,x)

```

which now gives ERROR: ArgumentError: broadcasting over dictionaries and `NamedTuple`s is reserved

---

<div class="post-metadata">

**Author:** ![Sijun](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Sijun](https://discourse.julialang.org/u/Sijun)\
**Post date:** [December 11, 2019, 6:25am UTC](https://discourse.julialang.org/t/dot-syntax-with-tuples/15222/5 "2019-12-11T06:25:27Z")

</div>

you can prevent broadcasting by Ref: `f.(y,Ref(x))`
