# Square bracket or parenthesis when dealing with the element of an array

**URL:** <https://community.freefem.org/t/square-bracket-or-parenthesis-when-dealing-with-the-element-of-an-array/4119>\
**Category:** General Discussion\
**Created:** [November 2, 2025, 7:01am UTC](https://community.freefem.org/t/square-bracket-or-parenthesis-when-dealing-with-the-element-of-an-array/4119 "2025-11-02T07:01:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MatrixVector](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@MatrixVector](https://community.freefem.org/u/MatrixVector)\
**Post date:** [November 2, 2025, 7:01am UTC](https://community.freefem.org/t/square-bracket-or-parenthesis-when-dealing-with-the-element-of-an-array/4119/1 "2025-11-02T07:01:58Z")

</div>

When dealing with the element of an array, it seems that both the square bracket `a[i]` and the parenthesis `a(i)` are OK. For example,

```cpp
real[int] U = 1:5;
for (int i = 0; i < U.n; i++ ) {
    cout << U(i) << endl;
}

```

```cpp
real[int] U = 1:5;
for (int i = 0; i < U.n; i++ ) {
    cout << U[i] << endl;
}

```

Which one is preferred, since both can be found in the discussions in the community.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [November 2, 2025, 7:10am UTC](https://community.freefem.org/t/square-bracket-or-parenthesis-when-dealing-with-the-element-of-an-array/4119/2 "2025-11-02T07:10:26Z")

</div>

They are the same, pick the one your prefer.
