# Square Bracket Notation for Broadcasting getindex Across Array of Vectors?

**URL:** https://discourse.julialang.org/t/square-bracket-notation-for-broadcasting-getindex-across-array-of-vectors/6227
**Category:** General Usage
**Tags:** plotting, array, linearalgebra
**Created:** [October 3, 2017, 7:51pm UTC](https://discourse.julialang.org/t/square-bracket-notation-for-broadcasting-getindex-across-array-of-vectors/6227 "2017-10-03T19:51:22Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [September 13, 2019, 1:14am UTC](https://discourse.julialang.org/t/square-bracket-notation-for-broadcasting-getindex-across-array-of-vectors/6227/6 "2019-09-13T01:14:30Z")

</div>

You can define the operator `..` do broadcast `getindex` and `getfield`, see

> [@Neat way of broadcasting getindex and getfield](https://discourse.julialang.org/t/neat-way-of-broadcasting-getindex-and-getfield/28706):
>
> I often find myself wanting to broadcast getindex and getfield, which is perfectly doable, but could enjoy a nicer syntax. I figured out if I define the operator .. in the right way, I get a kind-of nice syntax for doing this without macros: a = [randn(3) for \_ in 1:4]; b = [complex(i,i+1) for i in 1:4]; (..)(x::AbstractArray,i...) = getindex.(x,i...) (..)(x::AbstractArray,i::Symbol) = getfield.(x,i) julia\> a..2 == getindex.(a, 2) true julia\> b..:re == getfield.(b, :re) true Edit: To broadca…

---

_[View the full topic](https://discourse.julialang.org/t/square-bracket-notation-for-broadcasting-getindex-across-array-of-vectors/6227)._
