# Because size() doesn't work

**URL:** <https://discourse.julialang.org/t/because-size-doesnt-work/37939>\
**Category:** General Usage\
**Tags:** question\
**Created:** [April 21, 2020, 12:54am UTC](https://discourse.julialang.org/t/because-size-doesnt-work/37939 "2020-04-21T00:54:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![EmilioAlvizo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emilioalvizo/32/23406_2.png) [@EmilioAlvizo](https://discourse.julialang.org/u/EmilioAlvizo)\
**Post date:** [April 21, 2020, 12:54am UTC](https://discourse.julialang.org/t/because-size-doesnt-work/37939/1 "2020-04-21T00:54:58Z")

</div>

I want to size the array dimensions which in this case are 5 and 6, but I don’t know why it doesn’t

```julia
A=zeros(5,6)
size(A)

```

and I get the following error

**MethodError: objects of type Tuple{Int64,Int64} are not callable**

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [April 21, 2020, 12:58am UTC](https://discourse.julialang.org/t/because-size-doesnt-work/37939/2 "2020-04-21T00:58:18Z")

</div>

I think something in your environment overwrote the size() method. On my machine with 1.4.1:

```julia
julia> A=zeros(5,6)
5×6 Array{Float64,2}:
 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.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 0.0 0.0 0.0 0.0 0.0

julia> size(A)
(5, 6)

```

Try starting a clean session and retry it…

---

<div class="post-metadata">

**Author:** ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Post date:** [April 21, 2020, 1:18am UTC](https://discourse.julialang.org/t/because-size-doesnt-work/37939/3 "2020-04-21T01:18:13Z")

</div>

If you type `size` you’ll probably see a 2-item tuple returned. Maybe sometime earlier you wrote `size = size(A)`?

---

<div class="post-metadata">

**Author:** ![EmilioAlvizo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emilioalvizo/32/23406_2.png) [@EmilioAlvizo](https://discourse.julialang.org/u/EmilioAlvizo)\
**Post date:** [April 21, 2020, 1:20am UTC](https://discourse.julialang.org/t/because-size-doesnt-work/37939/4 "2020-04-21T01:20:33Z")

</div>

Thanks restart julia I solve it, sometimes julia goes crazy, it could also be for having written this

```julia
size = width, height = 600, 600

```

---

<div class="post-metadata">

**Author:** ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Post date:** [April 21, 2020, 1:31am UTC](https://discourse.julialang.org/t/because-size-doesnt-work/37939/5 "2020-04-21T01:31:14Z")

</div>

yep, that would definitely do it

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [April 21, 2020, 1:52am UTC](https://discourse.julialang.org/t/because-size-doesnt-work/37939/6 "2020-04-21T01:52:28Z")

</div>

you could still use `Base.size`, but the better answer is to not call variables size.

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [April 21, 2020, 2:07am UTC](https://discourse.julialang.org/t/because-size-doesnt-work/37939/7 "2020-04-21T02:07:22Z")

</div>

Note that this same problem happens if you have a line like `size = size(...)` in a function. And the error message that you get is a bit confusing:

```julia
julia> function foo()
           size = size([1, 2])
       end
foo (generic function with 1 method)

julia> foo()
ERROR: UndefVarError: size not defined

```

It’s even more confusing if first you call `size()` in a function and then later assign to a variable called `size` in the same function:

```julia
julia> function bar()
           s = size([1, 2])
           size = 1
           return nothing
       end
bar (generic function with 1 method)

julia> bar()
ERROR: UndefVarError: size not defined

```

This is an example of the effect proceeding the cause. Basically, if you assign to a local variable `size` anywhere inside a function, then the compiler treats each instance of `size` within that function scope as a local variable, even if an instance of `size` proceeds the local variable assignment.
