Learn Courses My Dashboard

When to use () after [variable]

I’am confusing when to use () after array of something like example below:
line 12


and this one (line 10,13 and line 36)

Can anyone please let me know the rule

The first screenshot line 12, that is defining a new array with 0 items in it

Line 10 of the 2nd screenshot is using an array as the return type for that function

Line 13 is returning an empty array

Line 36 is returning an empty array (with no items in it).

Many times () parenthesis are uses to initialize objects / call functions, this is the syntax (how the code is written).

You don’t initialize an empty array when defining what the return type is for a function, BUT inside the actual function, you may return an empty array, like lines 13 and 36.

Also next time your question should go in the App Development Category, rather than Community

1 Like

Thanks for your kindly reply!!!