# Declaration of variables

**URL:** https://discourse.julialang.org/t/declaration-of-variables/103508
**Category:** General Usage
**Tags:** question
**Created:** [September 4, 2023, 1:23pm UTC](https://discourse.julialang.org/t/declaration-of-variables/103508 "2023-09-04T13:23:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Alois](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alois/32/22558_2.png) [@Alois](https://discourse.julialang.org/u/Alois)
#### Post date: [September 4, 2023, 1:23pm UTC](https://discourse.julialang.org/t/declaration-of-variables/103508/1 "2023-09-04T13:23:39Z")

</div>

How is a variable declared as a simple Float64, say, without initializing it?  
Something like `A= Array{Float64, 0}(undef)`, which works for vectors.

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [September 4, 2023, 1:29pm UTC](https://discourse.julialang.org/t/declaration-of-variables/103508/2 "2023-09-04T13:29:17Z")

</div>

You don´t . A `Float64` is an immutable value, meaning that there is nothing that is its “existence” except its value. What you can is define its scope without giving it a value:

```julia
function f()
    local a
    for i in 1:3
        if i == 1
            a = 1 
        end
        a = a + 1
    end
    return a
end

```

(the function above errors if you remove `local a` because then a is not initialized in the second iteration of the loop, as the scope of `a` would be limited to the first iteration).

ps: You could there also use `local a::Float64` to specify the type of `a`).

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [September 4, 2023, 1:42pm UTC](https://discourse.julialang.org/t/declaration-of-variables/103508/3 "2023-09-04T13:42:00Z")

</div>

To nitpick I think `isbits` is a better abstraction than `isimmutable` here. Regardless a `Float64` is represented by exactly eight bytes, and all those 2^64 possible values correspond to a double precision number, so there’s no space to encode the state of not being initialized.
