January 18, 2011 const vs immutable | ||||
---|---|---|---|---|
| ||||
In cases where they are the same, for instance declaring: const int x = oldX + 5; vs immutable int x = oldX + 5; Or in non-class, non-array function parameters, does it make a difference which is used? |
January 19, 2011 Re: const vs immutable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Eskapp | Sean Eskapp Wrote:
> In cases where they are the same, for instance declaring: const int x = oldX + 5;
>
> vs
>
> immutable int x = oldX + 5;
>
> Or in non-class, non-array function parameters, does it make a difference which is used?
Use immutable, it documents the type better. And const items cannot be used as immutable parameters (value types don't have such restriction).
|
Copyright © 1999-2021 by the D Language Foundation