gas-optimizations
gas-optimizations copied to clipboard
Immutable State Variables vs. Constant
I believe the example for this optimization is not completely correct. Immutable should be used when the state variable is assigned in the constructor. If it is directly assigned in the declaration, then constant should be used. Not sure if it affects the gas used (which is the point of the repo), but I think that the example could make the point better if it assigns the variable in the constructor.
Another idea would be to show both cases (constant and immutable) in that section.
that's correct! i agree we should show both cases and ideally display gas costs for both