# Class actor constructor variables stable

**URL:** <https://forum.dfinity.org/t/class-actor-constructor-variables-stable/6399>\
**Category:** Developers\
**Created:** [August 10, 2021, 1:09pm UTC](https://forum.dfinity.org/t/class-actor-constructor-variables-stable/6399 "2021-08-10T13:09:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [August 10, 2021, 1:09pm UTC](https://forum.dfinity.org/t/class-actor-constructor-variables-stable/6399/1 "2021-08-10T13:09:48Z")

</div>

Are the constructor variables (not sure that’s the proper name, see examples below `n` and `i`) of a class actor **stable**? Are these values preserved when the related canister is upgraded?

```auto
import Nat "mo:base/Nat";

actor class Bucket(n : Nat, i : Nat) {
};

```

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [August 10, 2021, 2:29pm UTC](https://forum.dfinity.org/t/class-actor-constructor-variables-stable/6399/2 "2021-08-10T14:29:58Z")

</div>

No. You can save them to stable variables if you like though.

Note that the upgrade can specify its own parameters, and these need bare no relation to the parameters of the replaced actor.

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [August 10, 2021, 2:37pm UTC](https://forum.dfinity.org/t/class-actor-constructor-variables-stable/6399/3 "2021-08-10T14:37:55Z")

</div>

> [@claudio](#):
>
> No. You can save them to stable variables if you like thought.

Oh that was a good to ask! Thanks for the answer.

So if I get it, as following then.

```auto
import Nat "mo:base/Nat";

actor class Bucket(n : Nat) {
    private stable let n_stable: Nat = n;

    public query func get(): async Nat {
        return n_stable;
    }
};

```

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [August 10, 2021, 2:58pm UTC](https://forum.dfinity.org/t/class-actor-constructor-variables-stable/6399/4 "2021-08-10T14:58:44Z")

</div>

Yes, that should work.
